Skip to content

Commit

Permalink
fix query with aggregation
Browse files Browse the repository at this point in the history
  • Loading branch information
gpetretto committed Aug 29, 2023
1 parent c48634b commit 5c63247
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/jobflow_remote/fireworks/launchpad.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,8 @@ def generate_id_query(
if job_id:
query[FW_UUID_PATH] = job_id
if job_index is None:
# note: this format is suitable for collection.find(sort=.),
# but not for $sort in an aggregation.
sort = [[FW_INDEX_PATH, DESCENDING]]
else:
query[FW_INDEX_PATH] = job_index
Expand Down Expand Up @@ -623,7 +625,7 @@ def get_remote_run(
msg = f"No Remote run exists with fw id: {fw_id} or job_id {job_id}"
if job_index is not None:
msg += f" and job index {job_index}"
raise ValueError(msg)
raise ValueError(msg)

return RemoteRun.from_db_dict(remote_dict)

Expand Down
3 changes: 3 additions & 0 deletions src/jobflow_remote/jobs/jobcontroller.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,9 @@ def get_job_info(
f"{REMOTE_DOC_PATH}.error": 1,
}
)
if sort:
# needs to be converted when used in an aggregation
sort = dict(sort)
data = list(
self.rlpad.get_fw_launch_remote_run_data(
query=query, projection=proj, sort=sort, limit=1
Expand Down

0 comments on commit 5c63247

Please sign in to comment.