-
Notifications
You must be signed in to change notification settings - Fork 5
Feature/job log #142
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
Merged
Merged
Feature/job log #142
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
1168b45
Added ORM for Jobs and adjusted logging, reordered columns
bakspace-itk 8180032
Functionally complete
bakspace-itk a6c9f54
Added tests and changed passed objects to full Job, instead of ID. Fi…
bakspace-itk be96906
Formatted alembic revision, expanded scheduler tests and fixed JobSta…
bakspace-itk cf1231b
first stab from claude on testing job ui
bakspace-itk 9850375
Working tests and removed warnings from browser
bakspace-itk 399bee6
Linting and changelog
bakspace-itk 48c4019
Fixed job ID being set as string instead of UUID
bakspace-itk 80f9e9b
Fixed errors with UUID being set as string
bakspace-itk 15713ef
Fixed alembic test and added full drop to db_test_util
bakspace-itk 8b2f00c
Changed line order by which an imported module (sqlchemy) was causing…
bakspace-itk 5f36e18
Fix attempt of a null thing with sql stuff
bakspace-itk d303fdd
fixed tests, reordered tabs a bit, removed redundant code, made a col…
bakspace-itk 503a295
changed constant to uppercase
bakspace-itk 72363f3
fixed comment starting with "#" and not "# "
bakspace-itk ee0cc92
changed "constants" back to not-constants. And added version numbers …
bakspace-itk e5502e6
Removed string conversion to avoid hex error on github actions
bakspace-itk 962278c
Merged develop into branch
bakspace-itk 17d73c4
Added 1 second sleep to test browser opening, to make tests more reli…
bakspace-itk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| """This module defines ORM classes for jobs""" | ||
|
|
||
| from datetime import datetime | ||
| import enum | ||
| import uuid | ||
|
|
||
| from sqlalchemy import String | ||
| from sqlalchemy.orm import Mapped, mapped_column | ||
|
|
||
| from OpenOrchestrator.common import datetime_util | ||
| from OpenOrchestrator.database.base import Base | ||
|
|
||
| # All classes in this module are effectively dataclasses without methods. | ||
| # pylint: disable=too-few-public-methods | ||
|
|
||
|
|
||
| class JobStatus(enum.Enum): | ||
| """An enum representing the level of logs.""" | ||
| RUNNING = "Running" | ||
| DONE = "Done" | ||
| FAILED = "Failed" | ||
| KILLED = "Killed" | ||
|
|
||
|
|
||
| class Job(Base): | ||
| """A class representing job objects in the ORM.""" | ||
|
|
||
| __tablename__ = "Jobs" | ||
|
|
||
| id: Mapped[uuid.UUID] = mapped_column(primary_key=True, default=uuid.uuid4) | ||
| process_name: Mapped[str] = mapped_column(String(100)) | ||
| scheduler_name: Mapped[str] = mapped_column(String(100)) | ||
| status: Mapped[JobStatus] = mapped_column(default=JobStatus.RUNNING) | ||
| start_time: Mapped[datetime] = mapped_column(default=datetime.now) | ||
| end_time: Mapped[datetime] = mapped_column(default=None, nullable=True) | ||
|
|
||
| def to_row_dict(self) -> dict[str, str]: | ||
| """Convert log to a row dictionary for display in a table.""" | ||
| return { | ||
| "ID": str(self.id), | ||
| "Process Name": self.process_name, | ||
| "Scheduler": self.scheduler_name, | ||
| "Start Time": datetime_util.format_datetime(self.start_time), | ||
| "End Time": datetime_util.format_datetime(self.end_time), | ||
| "Status": self.status.value | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| """This module is responsible for the layout and functionality of the Schedulers tab | ||
| in Orchestrator.""" | ||
| from typing import Callable | ||
|
|
||
| from nicegui import ui | ||
|
|
||
| from OpenOrchestrator.database import db_util | ||
| from OpenOrchestrator.orchestrator import test_helper | ||
|
|
||
| COLUMNS = [ | ||
| {'name': "job_id", 'label': "ID", 'field': "ID", 'headerClasses': 'hidden', 'classes': 'hidden'}, | ||
| {'name': "process_name", 'label': "Process Name", 'field': "Process Name", 'align': 'left', 'sortable': True}, | ||
| {'name': "scheduler_name", 'label': "Scheduler", 'field': "Scheduler", 'align': 'left', 'sortable': True}, | ||
| {'name': "start_time", 'label': "Start Time", 'field': "Start Time", 'align': 'left', 'sortable': True}, | ||
| {'name': "end_time", 'label': "End Time", 'field': "End Time", 'align': 'left', 'sortable': True}, | ||
| {'name': "status", 'label': "Status", 'field': "Status", 'align': 'left', 'sortable': True} | ||
| ] | ||
|
|
||
|
|
||
| # pylint: disable-next=too-few-public-methods | ||
| class JobsTab: | ||
| """A class for the jobs tab.""" | ||
| def __init__(self, tab_name: str, on_job_click: Callable[[str], None]) -> None: | ||
| with ui.tab_panel(tab_name): | ||
| self.jobs_table = ui.table(title="Jobs", columns=COLUMNS, rows=[], row_key='job_id', pagination=50).classes("w-full") | ||
| self.jobs_table.on("rowClick", self._row_click) | ||
| self._add_column_colors() | ||
| test_helper.set_automation_ids(self, "jobs_tab") | ||
| self.on_job_click = on_job_click | ||
|
|
||
| def update(self): | ||
| """Updates the tables on the tab.""" | ||
| jobs = db_util.get_jobs() | ||
| self.jobs_table.rows = [s.to_row_dict() for s in jobs] | ||
|
|
||
| def _row_click(self, event): | ||
| row = event.args[1] | ||
| job_id = row["ID"] | ||
| self.on_job_click(job_id) | ||
|
|
||
| def _add_column_colors(self): | ||
| """Add custom coloring to the jobs table.""" | ||
| # Add coloring to the status column | ||
| color_dict = "{Running: 'blue', Done: 'green', Failed: 'red', Killed: 'grey-9'}" | ||
|
|
||
| self.jobs_table.add_slot( | ||
| "body-cell-status", | ||
| f''' | ||
| <q-td key="status" :props="props"> | ||
| <q-badge v-if="{color_dict}[props.value]" :color="{color_dict}[props.value]"> | ||
| {{{{props.value}}}} | ||
| </q-badge> | ||
| <p v-else> | ||
| {{{{props.value}}}} | ||
| </p> | ||
| </q-td> | ||
| ''' | ||
| ) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.