-
Notifications
You must be signed in to change notification settings - Fork 53
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
DATAUP-729: job timestamp easy pickings #2950
Conversation
@@ -1,30 +1,32 @@ | |||
""" | |||
A module for managing apps, specs, requirements, and for starting jobs. | |||
""" | |||
import datetime |
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.
all isort
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.
Nice!
@@ -79,8 +82,8 @@ | |||
STATE_ATTRS = list(set(JOB_ATTRS) - set(JOB_INPUT_ATTRS) - set(NARR_CELL_INFO_ATTRS)) | |||
|
|||
|
|||
class Job(object): | |||
_job_logs = list() | |||
class Job: |
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.
no need for (object)
in python 3
class Job(object): | ||
_job_logs = list() | ||
class Job: | ||
_job_logs = [] |
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.
from the flake8-comprehensions plugin (installed locally)
@@ -172,25 +175,25 @@ def __getattr__(self, name): | |||
""" | |||
Map expected job attributes to paths in stored ee2 state | |||
""" | |||
attr = dict( | |||
app_id=lambda: self._acc_state.get("job_input", {}).get( | |||
attr = { |
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.
flake8-comprehensions again
# Check if there would be no change in updating | ||
# i.e., if state <= self._acc_state | ||
if self._acc_state is not None: | ||
if {**self._acc_state, **state} == self._acc_state: | ||
return |
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.
prep for upcoming timestamps work
This pull request introduces 2 alerts when merging 3dc225d into 213fd59 - view on LGTM.com new alerts:
|
@@ -112,6 +114,11 @@ def cell_id_list(self): | |||
return self.rq_data[PARAM["CELL_ID_LIST"]] | |||
raise JobRequestException(CELLS_NOT_PROVIDED_ERR) | |||
|
|||
@property | |||
def ts(self): | |||
"""This param is completely optional""" |
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.
@n1mus is going to write a better description for this param in a forthcoming PR 😁
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.
xD :P
MESSAGE_TYPE["CANCEL"]: self.cancel_jobs, | ||
MESSAGE_TYPE["CELL_JOB_STATUS"]: self.get_job_states_by_cell_id, | ||
MESSAGE_TYPE["INFO"]: self.get_job_info, | ||
MESSAGE_TYPE["LOGS"]: self.get_job_logs, | ||
MESSAGE_TYPE["RETRY"]: self.retry_jobs, | ||
MESSAGE_TYPE["START_UPDATE"]: self._modify_job_updates, | ||
MESSAGE_TYPE["STATUS"]: self._get_job_states, | ||
MESSAGE_TYPE["STATUS_ALL"]: self._get_all_job_states, | ||
MESSAGE_TYPE["STATUS"]: self.get_job_states, | ||
MESSAGE_TYPE["STATUS_ALL"]: self.get_all_job_states, |
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.
renamed these methods for clarity and to make a better distinction between top level and internal methods
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.
Nice! This would always throw me for a loop now that I think of it
@@ -323,13 +331,12 @@ def _get_job_info(self, req: JobRequest) -> dict: | |||
self.send_comm_message(MESSAGE_TYPE["INFO"], job_info) | |||
return job_info | |||
|
|||
def __get_job_states(self, job_id_list) -> dict: | |||
def _get_job_states(self, job_id_list: list, ts: int = None) -> dict: |
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.
note new ts
parameter
Codecov Report
@@ Coverage Diff @@
## develop #2950 +/- ##
===========================================
+ Coverage 73.19% 73.25% +0.05%
===========================================
Files 36 36
Lines 3895 3903 +8
===========================================
+ Hits 2851 2859 +8
Misses 1044 1044
Continue to review full report at Codecov.
|
"return_list": 0, | ||
} | ||
) | ||
job_states = Job.query_ee2_states(job_ids, init=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.
@n1mus has consolidated most of the ee2 queries (apart from the workspace job fetch) to use the query_ee2_state(s)
functions.
@@ -186,15 +183,19 @@ def check_jobs_equal(self, jobl, jobr): | |||
for attr in JOB_ATTRS: | |||
self.assertEqual(getattr(jobl, attr), getattr(jobr, attr)) | |||
|
|||
def check_job_attrs_custom(self, job, exp_attr={}): | |||
def check_job_attrs_custom(self, job, exp_attr=None): |
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.
don't use mutable args as defaults
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.
Ha I've learned something
import unittest | ||
from unittest import mock | ||
import os | ||
import copy |
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.
isort got busy on this file!
@@ -1002,7 +1004,7 @@ def _generate_input(self, generator): | |||
if "prefix" in generator: | |||
ret = str(generator["prefix"]) + ret | |||
if "suffix" in generator: | |||
ret = ret + str(generator["suffix"]) | |||
return ret + str(generator["suffix"]) |
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.
? No biggie but I thought this was strange
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've got a flake8 plugin installed locally that warns if there's somewhere where a variable can be returned immediately. This is one such case...
@@ -112,6 +114,11 @@ def cell_id_list(self): | |||
return self.rq_data[PARAM["CELL_ID_LIST"]] | |||
raise JobRequestException(CELLS_NOT_PROVIDED_ERR) | |||
|
|||
@property | |||
def ts(self): | |||
"""This param is completely optional""" |
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.
xD :P
MESSAGE_TYPE["CANCEL"]: self.cancel_jobs, | ||
MESSAGE_TYPE["CELL_JOB_STATUS"]: self.get_job_states_by_cell_id, | ||
MESSAGE_TYPE["INFO"]: self.get_job_info, | ||
MESSAGE_TYPE["LOGS"]: self.get_job_logs, | ||
MESSAGE_TYPE["RETRY"]: self.retry_jobs, | ||
MESSAGE_TYPE["START_UPDATE"]: self._modify_job_updates, | ||
MESSAGE_TYPE["STATUS"]: self._get_job_states, | ||
MESSAGE_TYPE["STATUS_ALL"]: self._get_all_job_states, | ||
MESSAGE_TYPE["STATUS"]: self.get_job_states, | ||
MESSAGE_TYPE["STATUS_ALL"]: self.get_all_job_states, |
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.
Nice! This would always throw me for a loop now that I think of it
@@ -770,7 +771,7 @@ def list_jobs(self): | |||
""" | |||
try: | |||
all_states = self.get_all_job_states(ignore_refresh_flag=True) | |||
state_list = [s["jobState"] for s in all_states.values()] | |||
state_list = [copy.deepcopy(s["jobState"]) for s in all_states.values()] |
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.
Shouldn't need this anymore since we fixed the double- yet leaky-caching, but no biggie
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.
would you mind fixing it in the next PR?
@@ -186,15 +183,19 @@ def check_jobs_equal(self, jobl, jobr): | |||
for attr in JOB_ATTRS: | |||
self.assertEqual(getattr(jobl, attr), getattr(jobr, attr)) | |||
|
|||
def check_job_attrs_custom(self, job, exp_attr={}): | |||
def check_job_attrs_custom(self, job, exp_attr=None): |
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.
Ha I've learned something
3dc225d
to
52e379b
Compare
This pull request introduces 2 alerts when merging 52e379b into bcbad86 - view on LGTM.com new alerts:
|
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
Description of PR purpose/changes
This is a set of "easy pickings" from @n1mus (or Summit, as autocorrect calls her)'s DATAUP-729-job-ts branch. The original PR was large and complex so this updates and merges it into develop (see the first commit), and then picks out a small-ish set of changes for the first PR. It's expected that there will be (at least) two more PRs to cover the rest of the changes.
I ran
isort
, the import sorter, on the altered files.Jira Ticket / Issue
Related Jira ticket: https://kbase-jira.atlassian.net/browse/DATAUP-729
DATAUP-69 Adds a PR template
)Testing Instructions
Dev Checklist: