-
Notifications
You must be signed in to change notification settings - Fork 13
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
Job registry #54
Job registry #54
Conversation
kpsherva
commented
Aug 23, 2024
•
edited
Loading
edited
- closes jobs registry #49
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.
Seems that it's still in progress, but looks like pretty good to me 💯
Left some questions to get some more context.
invenio_jobs/assets/semantic-ui/js/invenio_jobs/administration/JobRunsHeader.js
Outdated
Show resolved
Hide resolved
invenio_jobs/assets/semantic-ui/js/invenio_jobs/administration/RunActionForm.js
Show resolved
Hide resolved
af84dd6
to
9b78b9d
Compare
invenio_jobs/models.py
Outdated
id = db.Column(UUIDType, primary_key=True, default=uuid.uuid4) | ||
active = db.Column(db.Boolean, default=True, nullable=False) | ||
title = db.Column(db.String(255), nullable=False) | ||
description = db.Column(db.Text) | ||
|
||
# default_args = db.Column(JSON, default=lambda: dict(), nullable=True) |
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.
attention: this is a breaking change, please let me know if you want to discuss
Looks good! Couple things
I think the text should say "Modifying the Custom args field will replace any arguments specified above and run the task with the custom configuration." (italics for the added words), or just "Modifying the Custom args field will replace any arguments specified above" |
My other feedback was about moving the Task selection to the top of the create page and auto-filling the task title |
5eb1349
to
cffab7f
Compare
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.
LGTM overall, I think it's best as we said to discuss IRL at some point to go quickly through the comments
@@ -125,20 +159,28 @@ class Meta: | |||
|
|||
task = fields.String( | |||
required=True, | |||
validate=LazyOneOf(choices=lambda: current_jobs.tasks.keys()), | |||
validate=LazyOneOf(choices=lambda: [name for name, t in Task.all().items()]), |
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.
validate=LazyOneOf(choices=lambda: [name for name, t in Task.all().items()]), | |
validate=LazyOneOf(choices=lambda: Task.all().keys(), |
nit: isn't that the same?
@@ -46,6 +46,7 @@ def execute_run(self, run_id, kwargs=None): | |||
run, | |||
status=RunStatusEnum.FAILED, | |||
finished_at=datetime.now(timezone.utc), | |||
message=f"{e.__class__.__name__}: {str(e)}", |
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.
minor: maybe it makes sense to store the whole exception stacktrace here? I saw roughly how it looks in the UI in the demo, but e.g. if it's something small like KeyError: "id" not found
, it'll be difficult to debug. Of course logging is the long term solution, but maybe for now that would be a small improvement that's good enough to get by
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.
I will check if it is an easy win. Otherwise, I will ticketize it since it is a bit out of scope
invenio_jobs/services/schema.py
Outdated
load_default=lambda: current_jobs.default_queue, | ||
dump_default=lambda: current_jobs.default_queue, |
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.
minor: this should default to the Job's default queue, i.e. job.default_queue
.
schedule = db.Column(JSON, nullable=True) | ||
|
||
@property | ||
def last_run(self): | ||
"""Last run of the job.""" | ||
return self.runs.order_by(Run.created.desc()).first() | ||
_run = self.runs.order_by(Run.created.desc()).first() | ||
return _run if _run else {} |
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.
minor: isn't it cleaner/more-consistent to return None
here?
invenio_jobs/services/schema.py
Outdated
|
||
def __init__(self, *args, **kwargs): | ||
"""Constructor.""" | ||
self.type_schemas = deepcopy(current_jobs.registry.registered_schemas()) |
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.
minor: can this be "lazy", via e.g. a property? In general when we start using current_xxx
and Flask app-context in __init__
, we end up in difficult situations in config/schemas.
invenio_jobs/assets/semantic-ui/js/invenio_jobs/administration/ScheduleJobModal.js
Show resolved
Hide resolved
lambda: RegisteredTaskArgumentsSchema, | ||
metadata={ | ||
"type": "dynamic", | ||
"endpoint": "/api/tasks/<item_id>/args", |
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.
question: out of curiosity how is this metadata
used?
metadata={ | ||
"type": "dynamic", | ||
"endpoint": "/api/tasks/<item_id>/args", | ||
"depends_on": "task", |
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.
question: also this?
this.setState({ | ||
modalOpen: false, | ||
modalHeader: undefined, | ||
modalBody: undefined, | ||
}); | ||
setTimeout(() => { | ||
window.location.reload(); | ||
window.location = resource.links.self_admin_html; |
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.
What is this timeout of 1 sec?
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.
This is when we create a new job run and we switch to detail view of this run (to monitor it).
@0einstein0 was the 1s chosen for any specific reason?
invenio_jobs/assets/semantic-ui/js/invenio_jobs/administration/RunActionForm.js
Outdated
Show resolved
Hide resolved
@@ -34,11 +34,12 @@ def get_job_id(self, instance): | |||
return job_id | |||
raise KeyError("Job not found in registry.") | |||
|
|||
def all_registered_jobs(self): | |||
def get_all(self): |
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.
similary this could be a property as well i.e. all methods of def method(self)
Do the screenshots in the first comment need updating? |
* tests: adapt tests to new implementation of jobs registry * chore: fix formatting
* tests: fix expected outputs
359ccf7
to
e50f4a9
Compare
e50f4a9
to
77f2c45
Compare