-
Notifications
You must be signed in to change notification settings - Fork 9
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
JSON output for hq job list and hq submit #24
Conversation
Instead of using regex to parse the command output, HQ provide output mode JSON which we can get output to a dict to avoid using regex.
for more information, see https://pre-commit.ci
Hi @unkcpz |
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.
Just a small comment, apart from that it's fine
job_info = JobInfo() | ||
job_info.job_id = hq_job_dict["id"] | ||
job_info.title = hq_job_dict["name"] | ||
stats: t.List[str] = [ |
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.
Mainly out of curiosity, why do you explicitly add a type hint here? I'm mainly thinking about consistency, as I didn't see it anywhere else in the plugin apart from the function definitions?
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.
Just to make my IDE happy, I am using neovim with ruff check, which is quite strict on typing. The type of elements in the list is deducted from the key of hq_job_dict["task_stats"]
.
By tell my LSP the type of element explicitly, stats[0]
knows it is a str and help me to hint upper()
is a valid method to call.
Yes, I'll consider it for the tests. Thanks a lot for including me in the precious aiidateam org 😄 |
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.
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.
fixes #13
Instead of using regex to parse the command output, HQ provide output mode JSON which we can get output to a dict to avoid using regex.