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

Change id field passed to JobInfo from int to str #30

Merged
merged 2 commits into from
Jul 22, 2024

Conversation

unkcpz
Copy link
Member

@unkcpz unkcpz commented Jul 20, 2024

fixes #29

The id field of JobInfo is expecting a str. In #24 when parsing JSON output of hq job list the json loads will use the int for the id parsed directly. Wrong type causes the subtle issue that when job is waiting it not get into QUEUED state, but immediatly finished and get nothing to parse from output.

unkcpz and others added 2 commits July 20, 2024 04:49
fixes aiidateam#29

The id field of JobInfo is expecting a str. In aiidateam#24 when parsing JSON
output of `hq job list` the json loads will use the int for the id
parsed directly. Wrong type causes the subtle issue that when job is
waiting it not get into QUEUED state, but immediatly finished and get
nothing to parse from output.
@@ -228,7 +228,9 @@ def _parse_joblist_output(self, retval: int, stdout: str, stderr: str) -> list:
job_info_list = []
for hq_job_dict in hq_job_info_list:
job_info = JobInfo()
job_info.job_id = hq_job_dict["id"]
job_info.job_id = str(
Copy link
Member Author

Choose a reason for hiding this comment

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

This bug cost me couple of hours to locate it. Maybe in the aiida-core it can provide type check to avoid scheduler passing wrong datatype? @sphuber

Copy link

Choose a reason for hiding this comment

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

The JobInfo is part of the many data classes that are used that are defined as the custom DefaultFieldsAttributeDict. They really should be replaced with a dataclass but not sure about backwards compatibility. Also not sure there is much we can do about this now as long as it remains a DefaultFieldsAttributeDict.

That being said, how exactly did this bug manifest? I think it should automatically be cast into str somewhere. If not, it might just be a bug in aiida-core.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks @sphuber I dig a bit more into source of the issue (aiidateam/aiida-core#6542), but didn't able to find a good solution.

@unkcpz unkcpz requested a review from t-reents July 20, 2024 02:54
Copy link
Contributor

@t-reents t-reents left a comment

Choose a reason for hiding this comment

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

Thanks @unkcpz

@unkcpz
Copy link
Member Author

unkcpz commented Jul 22, 2024

Thanks @t-reents for reviewing. I'll merge this as a workaround.

@unkcpz unkcpz merged commit 40ac153 into aiidateam:main Jul 22, 2024
3 checks passed
@unkcpz unkcpz deleted the fix/29/jobid-str branch July 22, 2024 09:25
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.

Job not wait properly but immediately finished with error because job id of JobInfo is an int
3 participants