Skip to content
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

Merged
merged 12 commits into from
Sep 26, 2024
Merged

Job registry #54

merged 12 commits into from
Sep 26, 2024

Conversation

kpsherva
Copy link
Contributor

@kpsherva kpsherva commented Aug 23, 2024

Copy link

@jrcastro2 jrcastro2 left a 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/administration/jobs.py Show resolved Hide resolved
invenio_jobs/administration/jobs.py Show resolved Hide resolved
invenio_jobs/administration/runs.py Outdated Show resolved Hide resolved
invenio_jobs/models.py Outdated Show resolved Hide resolved
invenio_jobs/models.py Outdated Show resolved Hide resolved
invenio_jobs/models.py Outdated Show resolved Hide resolved
invenio_jobs/models.py Outdated Show resolved Hide resolved
invenio_jobs/services/services.py Show resolved Hide resolved
@kpsherva kpsherva force-pushed the job-registry branch 5 times, most recently from af84dd6 to 9b78b9d Compare August 26, 2024 14:44
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)
Copy link
Contributor Author

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

@carlinmack
Copy link
Contributor

carlinmack commented Aug 27, 2024

image

Looks good! Couple things

  1. I think this arrow is pointing the wrong way? Normally it goes from > to v (like on https://about.zenodo.org/roadmap/) but it goes from v to <
  2. I think the banner should go below the config, especially as you above in the text
  3. It would be nice to have a "copy to clipboard" button Ah I didn't realise that the reference config already has the ability to copy to clipboard! I think it only really makes sense to copy the full thing, but this implementation is fine as it is

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"

@carlinmack
Copy link
Contributor

My other feedback was about moving the Task selection to the top of the create page and auto-filling the task title

@kpsherva kpsherva force-pushed the job-registry branch 2 times, most recently from 5eb1349 to cffab7f Compare August 28, 2024 13:14
Copy link
Member

@slint slint left a 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

invenio_jobs/models.py Show resolved Hide resolved
invenio_jobs/models.py Show resolved Hide resolved
@@ -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()]),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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?

invenio_jobs/services/services.py Outdated Show resolved Hide resolved
@@ -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)}",
Copy link
Member

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

Copy link
Contributor Author

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

Comment on lines 244 to 245
load_default=lambda: current_jobs.default_queue,
dump_default=lambda: current_jobs.default_queue,
Copy link
Member

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.

invenio_jobs/models.py Outdated Show resolved Hide resolved
invenio_jobs/models.py Outdated Show resolved Hide resolved
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 {}
Copy link
Member

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?


def __init__(self, *args, **kwargs):
"""Constructor."""
self.type_schemas = deepcopy(current_jobs.registry.registered_schemas())
Copy link
Member

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.

lambda: RegisteredTaskArgumentsSchema,
metadata={
"type": "dynamic",
"endpoint": "/api/tasks/<item_id>/args",
Copy link
Member

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",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: also this?

tests/resources/test_resources.py Outdated Show resolved Hide resolved
invenio_jobs/jobs.py Outdated Show resolved Hide resolved
invenio_jobs/jobs.py Outdated Show resolved Hide resolved
invenio_jobs/jobs.py Outdated Show resolved Hide resolved
invenio_jobs/registry.py Show resolved Hide resolved
invenio_jobs/registry.py Outdated Show resolved Hide resolved
invenio_jobs/registry.py Outdated Show resolved Hide resolved
this.setState({
modalOpen: false,
modalHeader: undefined,
modalBody: undefined,
});
setTimeout(() => {
window.location.reload();
window.location = resource.links.self_admin_html;
Copy link
Contributor

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?

Copy link
Contributor Author

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?

@@ -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):
Copy link
Member

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)

@carlinmack
Copy link
Contributor

Do the screenshots in the first comment need updating?

@kpsherva kpsherva force-pushed the job-registry branch 2 times, most recently from 359ccf7 to e50f4a9 Compare September 17, 2024 14:13
@kpsherva kpsherva merged commit 36e59c7 into inveniosoftware:master Sep 26, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

jobs registry
6 participants