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

Refactored TemporaryFile and GitRepository into context managers. #772

Merged
merged 2 commits into from
Oct 20, 2021

Conversation

dblock
Copy link
Member

@dblock dblock commented Oct 20, 2021

Description

Refactored TemporaryFile and GitRepository into context managers.

On top of #768, extracted from #767

Check List

  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@dblock dblock force-pushed the context-managers branch 2 times, most recently from 9494d47 to c2bbf2f Compare October 20, 2021 16:38
@dblock dblock changed the title Refactored TeporaryFile and GitRepository into context managers. Refactored TemporaryFile and GitRepository into context managers. Oct 20, 2021
@codecov-commenter
Copy link

codecov-commenter commented Oct 20, 2021

Codecov Report

Merging #772 (c2bbf2f) into main (8af675b) will increase coverage by 0.00%.
The diff coverage is 86.59%.

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #772   +/-   ##
=======================================
  Coverage   91.30%   91.30%           
=======================================
  Files          75       75           
  Lines        1990     2002   +12     
=======================================
+ Hits         1817     1828   +11     
- Misses        173      174    +1     
Impacted Files Coverage Δ
src/run_perf_test.py 0.00% <0.00%> (ø)
src/system/config_file.py 93.02% <ø> (ø)
src/system/properties_file.py 97.36% <ø> (ø)
src/test_workflow/test_recorder/test_recorder.py 46.26% <0.00%> (ø)
...rc/test_workflow/test_recorder/test_result_data.py 100.00% <ø> (ø)
src/test_workflow/test_result/test_result.py 88.88% <0.00%> (ø)
..._workflow/opensearch/build_artifact_check_maven.py 94.73% <50.00%> (ø)
src/run_ci.py 82.35% <70.00%> (ø)
src/ci_workflow/ci.py 60.00% <75.00%> (ø)
src/run_build.py 85.00% <75.00%> (ø)
... and 42 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6bef043...c2bbf2f. Read the comment docs.

logging.info(f"Checking out components into {work_dir}")
os.chdir(work_dir)
logging.info(f"Checking out components into {work_dir.name}")
os.chdir(work_dir.name)
Copy link
Contributor

Choose a reason for hiding this comment

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

Just curious: do we need this since mkdtemp is removed in the latest commit?

Copy link
Member Author

@dblock dblock Oct 20, 2021

Choose a reason for hiding this comment

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

Yes, mkdtemp was just a class method that called and retured TemporaryDirectory(keep=True/False), hence redundant. The object returned is still TemporaryDirectory that has a method called .name.

Signed-off-by: dblock <dblock@amazon.com>
logging.info(f"Bundling {build.name} ({build.architecture}) on {build.platform} into {output_dir} ...")

os.chdir(work_dir)
os.chdir(work_dir.name)
Copy link
Member

Choose a reason for hiding this comment

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

Nit: Just a thought, instead of os.chdir can we use WorkingDirectory here and for the rest?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point, #775

@dblock dblock merged commit b2fe209 into opensearch-project:main Oct 20, 2021
@dblock dblock deleted the context-managers branch October 20, 2021 23:11
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

4 participants