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

Files used by jobs need to be on a shared FS. This is typically the case #448

Merged
merged 2 commits into from
Feb 11, 2024

Conversation

hategan
Copy link
Collaborator

@hategan hategan commented Feb 10, 2024

except that the ci_runner, when testing various branches, does the cloning in /tmp. One alternative solution would be to ensure this is moved to the home dir.

This was basically why test_prelaunch and test_nodefile failed.

except that the ci_runner, when testing various branches, does the cloning
in `/tmp`. One alternative solution would be to ensure this is moved to
the home dir.
@hategan hategan requested a review from andre-merzky February 10, 2024 18:29
Copy link

codecov bot commented Feb 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (06e104b) 74.48% compared to head (40feee5) 74.60%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #448      +/-   ##
==========================================
+ Coverage   74.48%   74.60%   +0.11%     
==========================================
  Files          94       94              
  Lines        3872     3890      +18     
==========================================
+ Hits         2884     2902      +18     
  Misses        988      988              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@andre-merzky andre-merzky left a comment

Choose a reason for hiding this comment

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

left a comment, otherwise looks good to me - thanks!

# returns the resulting path
if isinstance(path, str):
path = Path(path)
with tempfile.NamedTemporaryFile(dir=Path.home() / '.psij' / 'test', delete=False) as df:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why the delete=False and finally instead of delete=True (which is the default anyway):

with tempfile.NamedTemporaryFile(dir=Path.home() / '.psij' / 'test') as df:
    shutil.copyfile(path, df.name)
    yield Path(df.name)

Copy link
Collaborator Author

@hategan hategan Feb 10, 2024

Choose a reason for hiding this comment

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

Good point and thanks for commenting on this, since I forgot to close the file. With delete=True it deletes on close. So if the scenario is to manipulate the file outside of python, you'd close it and pass the name around instead. Without delete=False, the file will be deleted as soon as it is closed. The need to close is because on some platforms (Windows) the file cannot be opened concurrently. The question that the Python documentation doesn't answer is whether, if the file is deleted, the name property would still be guaranteed to be valid. The wording of the documentation suggests that this may not be the case, although a quick test shows that it is (on my laptop).

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah, makes sense now, thanks!

@@ -67,6 +67,7 @@ def _deploy(path: Union[Path, str]) -> Iterator[Path]:
path = Path(path)
with tempfile.NamedTemporaryFile(dir=Path.home() / '.psij' / 'test', delete=False) as df:
try:
df.close()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah! :-D

@hategan hategan merged commit 060ab83 into main Feb 11, 2024
13 checks passed
@hategan hategan deleted the fix_some_tests branch February 11, 2024 06:53
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.

2 participants