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

[zos-jobs] Added support for cancel_job version number on requests #106

Closed

Conversation

aadityasinha-dotcom
Copy link
Contributor

Added an optional modifyVersion parameter to the cancel_job API with a default value of "2.0"

Signed-off-by: aadityasinha-dotcom <aadityasinha009@gmail.com>
@codecov
Copy link

codecov bot commented Aug 11, 2022

Codecov Report

Base: 73.70% // Head: 63.98% // Decreases project coverage by -9.71% ⚠️

Coverage data is based on head (77f86e2) compared to base (5618c82).
Patch coverage: 33.33% of modified lines in pull request are covered.

❗ Current head 77f86e2 differs from pull request most recent head 7173c08. Consider uploading reports for the commit 7173c08 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             next     #106      +/-   ##
==========================================
- Coverage   73.70%   63.98%   -9.72%     
==========================================
  Files          29       28       -1     
  Lines        1198     1008     -190     
==========================================
- Hits          883      645     -238     
- Misses        315      363      +48     
Flag Coverage Δ
unittests 63.98% <33.33%> (-9.72%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/zos_jobs/zowe/zos_jobs_for_zowe_sdk/jobs.py 15.38% <33.33%> (-7.98%) ⬇️
src/zos_files/zowe/zos_files_for_zowe_sdk/files.py 38.72% <0.00%> (-22.94%) ⬇️
src/zosmf/zowe/zosmf_for_zowe_sdk/zosmf.py 71.42% <0.00%> (-11.91%) ⬇️
tests/unit/test_zowe_core.py 98.44% <0.00%> (-0.23%) ⬇️
tests/unit/test_zosmf.py 100.00% <0.00%> (ø)
tests/unit/test_zos_jobs.py 100.00% <0.00%> (ø)
tests/unit/test_zos_files.py 100.00% <0.00%> (ø)
...os_files/zowe/zos_files_for_zowe_sdk/exceptions.py 100.00% <0.00%> (ø)
src/core/zowe/core_for_zowe_sdk/validators.py

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@t1m0thyj
Copy link
Member

@aadityasinha-dotcom Thanks for your contribution 🙂 Please add unit and integration tests for the cancel_job API modeled after the ones you wrote in #97.

Signed-off-by: Aaditya Sinha <75474786+aadityasinha-dotcom@users.noreply.github.com>
Copy link
Member

@zFernand0 zFernand0 left a comment

Choose a reason for hiding this comment

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

Thanks for working on this.
I left some comments that could improve the overall usage of the API 😋

One additional consideration.
There are some z/OSMF REST APIs that don't return all headers if the response is empty.
For that reason, maybe we should consider the following small change too:
From self.response.headers['Content-Type'] to self.response.headers.get('Content-Type') in
src/core/zowe/core_for_zowe_sdk/request_handler.py

(Thanks @t1m0thyj for helping me understand what was happening)

def cancel_job(self, jobname: str, jobid: str, modify_version="2.0"):
def cancel_job(self, jobname, jobid, modifyVersion="1.0"):
Copy link
Member

Choose a reason for hiding this comment

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

will it be considered a breaking change if we change the modifyVersion default value ?
Maybe it should stay at 2.0 (synchronous by default) since there are other z/OS configuration considerations (e.g. CIM Authorization) for asynchronous requests.

@@ -56,7 +56,7 @@ def get_job_status(self, jobname, jobid):
response_json = self.request_handler.perform_request("GET", custom_args)
return response_json

def cancel_job(self, jobname: str, jobid: str, modify_version="2.0"):
Copy link
Member

Choose a reason for hiding this comment

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

I believe there is a missing modify_version to be renamed to modifyVersion
I don't know what the convention is, but it seems that this file is mostly using snake_case instead of camelCase

Can we rename it back to modify_version ?

Comment on lines +83 to +86
custom_args["json"] = {"request": "cancel", "version": modifyVersion}
response_json = self.request_handler.perform_request("PUT", custom_args, expected_code = [202])
custom_args["json"] = {"request": "cancel"}
response_json = self.request_handler.perform_request("PUT", custom_args, expected_code=[202])
Copy link
Member

Choose a reason for hiding this comment

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

Please remove the duplicate REST calls and use 202, 200 for the expected_code.

@t1m0thyj
Copy link
Member

Looks like this enhancement was already made in #124. Sorry about that 😢 Going forward, we can avoid this happening again by making sure to assign issues to avoid duplicate work 🙂

@t1m0thyj t1m0thyj closed this Sep 19, 2022
@aadityasinha-dotcom aadityasinha-dotcom deleted the cancel_jobs_version branch September 19, 2022 14:33
@aadityasinha-dotcom
Copy link
Contributor Author

Looks like this enhancement was already made in #124. Sorry about that 😢 Going forward, we can avoid this happening again by making sure to assign issues to avoid duplicate work 🙂

No worries

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.

None yet

3 participants