-
Notifications
You must be signed in to change notification settings - Fork 13
Add tracking of submitted transforms #634
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,6 +62,7 @@ def list(): | |
table.add_column("Files") | ||
table.add_column("Format") | ||
runs = cache.cached_queries() | ||
pending = cache.submitted_queries() | ||
for r in runs: | ||
table.add_row( | ||
r.title, | ||
|
@@ -71,6 +72,15 @@ def list(): | |
str(r.files), | ||
r.result_format, | ||
) | ||
for r in pending: | ||
table.add_row( | ||
r.get("title", ""), | ||
r.get("codegen", ""), | ||
r.get("request_id", ""), | ||
"Pending", | ||
"Pending", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In particular as to what is shown to the users |
||
str(r.get("result_format", "")), | ||
) | ||
rich.print(table) | ||
|
||
|
||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -29,6 +29,7 @@ | |||||
import os | ||||||
from pathlib import Path | ||||||
from typing import List, Optional | ||||||
from datetime import datetime, timezone | ||||||
from filelock import FileLock | ||||||
from tinydb import TinyDB, Query, where | ||||||
|
||||||
|
@@ -148,6 +149,24 @@ def update_transform_request_id(self, hash_value: str, request_id: str) -> None: | |||||
transform.hash == hash_value, | ||||||
) | ||||||
|
||||||
def cache_submitted_transform( | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. prefer not to have a submitted-only code path |
||||||
self, transform: TransformRequest, request_id: str | ||||||
) -> None: | ||||||
"""Cache a transform that has been submitted but not completed.""" | ||||||
|
||||||
record = { | ||||||
"hash": transform.compute_hash(), | ||||||
"title": transform.title, | ||||||
"codegen": transform.codegen, | ||||||
"result_format": transform.result_format, | ||||||
"request_id": request_id, | ||||||
"status": "SUBMITTED", | ||||||
"submit_time": datetime.now(timezone.utc).isoformat(), | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [nitpick] Consider accepting submit_time as a parameter to make the method more testable and flexible, rather than always using the current time.
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||
} | ||||||
transforms = Query() | ||||||
with self.lock: | ||||||
self.db.upsert(record, transforms.hash == record["hash"]) | ||||||
|
||||||
def get_transform_by_hash(self, hash: str) -> Optional[TransformedResults]: | ||||||
""" | ||||||
Returns completed transformations by hash | ||||||
|
@@ -203,6 +222,17 @@ def cached_queries(self) -> List[TransformedResults]: | |||||
] | ||||||
return result | ||||||
|
||||||
def submitted_queries(self) -> List[dict]: | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can this be generalized to return queries in a specified state (not just submitted)? |
||||||
"""Return all transform records that are only submitted.""" | ||||||
transforms = Query() | ||||||
with self.lock: | ||||||
return [ | ||||||
doc | ||||||
for doc in self.db.search( | ||||||
(transforms.status == "SUBMITTED") & transforms.request_id.exists() | ||||||
) | ||||||
] | ||||||
|
||||||
def delete_record_by_request_id(self, request_id: str): | ||||||
with self.lock: | ||||||
self.db.remove(where("request_id") == request_id) | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please change "pending" to "submitted"