-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Update Job.get_status and Job.restore to consistently return JobStatus Enum #2039
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
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #2039 +/- ##
==========================================
+ Coverage 93.61% 93.76% +0.14%
==========================================
Files 28 29 +1
Lines 3758 3863 +105
==========================================
+ Hits 3518 3622 +104
- Misses 240 241 +1 ☔ View full report in Codecov by Sentry. |
rq/job.py
Outdated
| return None | ||
|
|
||
| def get_status(self, refresh: bool = True) -> JobStatus: | ||
| def get_status(self, refresh: bool = True) -> Optional[JobStatus]: |
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 think get_status() should always returns something. If the job hash in Redis has no status, raise an exception.
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.
Thank you for the note. I updated it to raise an exception if there's no status in Redis. I added a status=JobStatus.QUEUED to a few Job.create calls in other tests so that they wouldn't fail as a result. I don't think this changed the purpose or accuracy of those tests.
| status = self.connection.hget(self.key, 'status') | ||
| self._status = as_text(status) if status else None | ||
| if not status: | ||
| raise InvalidJobOperation(f"Failed to retrieve status for job: {self.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.
Mind updating the test to test this code path so it can pass Codecov's test?
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.
sure thing!
|
Thanks! |
…alidJobOperation; see rq/rq#2039 Signed-off-by: F.N. Claessen <[email protected]>
* feat: test for Python 3.12 * feat: packages for Python 3.12 * fix: called_once_with should be assert_called_once_with Signed-off-by: F.N. Claessen <[email protected]> * fix: don't assert assert_method Signed-off-by: F.N. Claessen <[email protected]> * docs: changelog entry Signed-off-by: F.N. Claessen <[email protected]> * docs: add Python 3.12 classifier in setup.py Signed-off-by: F.N. Claessen <[email protected]> * fix: getting the status of a not yet queued job now results in an InvalidJobOperation; see rq/rq#2039 Signed-off-by: F.N. Claessen <[email protected]> --------- Signed-off-by: F.N. Claessen <[email protected]>
* feat: test for Python 3.12 * feat: packages for Python 3.12 * fix: called_once_with should be assert_called_once_with Signed-off-by: F.N. Claessen <[email protected]> * fix: don't assert assert_method Signed-off-by: F.N. Claessen <[email protected]> * docs: changelog entry Signed-off-by: F.N. Claessen <[email protected]> * docs: add Python 3.12 classifier in setup.py Signed-off-by: F.N. Claessen <[email protected]> * fix: getting the status of a not yet queued job now results in an InvalidJobOperation; see rq/rq#2039 Signed-off-by: F.N. Claessen <[email protected]> --------- Signed-off-by: F.N. Claessen <[email protected]> (cherry picked from commit faf7f55) Signed-off-by: F.N. Claessen <[email protected]>
…alidJobOperation; see rq/rq#2039 Signed-off-by: F.N. Claessen <[email protected]>
… in MW (#1234) * feat: `flexmeasures add sensor` no longer requires setting a capacity in MW Signed-off-by: F.N. Claessen <[email protected]> * docs: changelog entry Signed-off-by: F.N. Claessen <[email protected]> * docs: CLI changelog entry Signed-off-by: F.N. Claessen <[email protected]> * fix: getting the status of a not yet queued job now results in an InvalidJobOperation; see rq/rq#2039 Signed-off-by: F.N. Claessen <[email protected]> * docs: explain abbreviation used in changelog Signed-off-by: F.N. Claessen <[email protected]> * docs: fix typo Signed-off-by: F.N. Claessen <[email protected]> * docs: format CLI option and correct nomenclature (a flag is a boolean option, which this isn't) Signed-off-by: F.N. Claessen <[email protected]> --------- Signed-off-by: F.N. Claessen <[email protected]>
… in MW (#1234) * feat: `flexmeasures add sensor` no longer requires setting a capacity in MW Signed-off-by: F.N. Claessen <[email protected]> * docs: changelog entry Signed-off-by: F.N. Claessen <[email protected]> * docs: CLI changelog entry Signed-off-by: F.N. Claessen <[email protected]> * fix: getting the status of a not yet queued job now results in an InvalidJobOperation; see rq/rq#2039 Signed-off-by: F.N. Claessen <[email protected]> * docs: explain abbreviation used in changelog Signed-off-by: F.N. Claessen <[email protected]> * docs: fix typo Signed-off-by: F.N. Claessen <[email protected]> * docs: format CLI option and correct nomenclature (a flag is a boolean option, which this isn't) Signed-off-by: F.N. Claessen <[email protected]> --------- Signed-off-by: F.N. Claessen <[email protected]> (cherry picked from commit 772f73e)
I wrote up what I found in issue #2038, so I though I should create a PR with my suggested fixes.