Skip to content

Commit

Permalink
working on run log working
Browse files Browse the repository at this point in the history
  • Loading branch information
mdekstrand committed Dec 17, 2024
1 parent 63aa45b commit fd7445d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
4 changes: 2 additions & 2 deletions codex/runlog.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ class CodexTask(Task):
lenskit_version: str = lenskit.__version__ # type: ignore
tags: list[str] = Field(default_factory=list)

model: str | None = None
model_config: str | dict[str, JsonValue] | None = None
score_model: str | None = None
score_model_config: str | dict[str, JsonValue] | None = None

cpu_power: float | None = None
gpu_power: float | None = None
Expand Down
2 changes: 1 addition & 1 deletion codex/splitting/crossfold.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def crossfold_ratings(db: DuckDBPyConnection, cross: CrossfoldSpec, hold: Holdou
db.execute(
"""
INSERT INTO test_alloc (partition, user_id, item_id)
SELECT ?, user, item FROM test_df
SELECT ?, user_id, item_id FROM test_df
""",
[i],
)
16 changes: 10 additions & 6 deletions codex/tools/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def generate(
connect_cluster() as cluster,
ResultDB(db, store_predictions=predict) as results,
CodexTask(
label=f"generate-{model}", tags=["generate"], model=model, model_config=cfg
label=f"generate-{model}", tags=["generate"], score_model=model, score_model_config=cfg
) as root_task,
):
log = _log.bind(task_id=root_task.task_id)
Expand All @@ -108,10 +108,10 @@ def generate(
label=f"generate-{model}/train",
tags=["train"],
reset_hwm=True,
model=model,
model_config=cfg,
score_model=model,
score_model_config=cfg,
) as task:
trainable.train(data.train_data(db))
trainable.train(data.train_data(ratings_db))

plog.debug("run record: %s", task.model_dump_json(indent=2))
plog.info(
Expand All @@ -129,7 +129,11 @@ def generate(
plog.error("no test data found")

with CodexTask(
label=f"generate-{model}/recommend", tags=["recommend"], reset_hwm=True
label=f"generate-{model}/recommend",
tags=["recommend"],
reset_hwm=True,
score_model=model,
score_model_config=cfg,
) as task:
for result in run_recommender(
trainable, test, list_length, predict, cluster=cluster
Expand Down Expand Up @@ -157,7 +161,7 @@ def fixed_test_sets(test: Path, train: list[Path]) -> Generator[tuple[int, Train
def crossfold_test_sets(
assign: Path, ratings: Path, parts: str
) -> Generator[tuple[int, TrainTestData]]:
with connect(fspath(assign)) as db:
with connect(fspath(assign), read_only=True) as db:
db.execute(
"SELECT DISTINCT partition FROM test_alloc",
)
Expand Down

0 comments on commit fd7445d

Please sign in to comment.