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

Enable support for multi-process pytwin import #103

Merged
merged 5 commits into from
Aug 25, 2023
Merged

Conversation

lboucin
Copy link
Collaborator

@lboucin lboucin commented Aug 1, 2023

Make working directory unique to each process
resolves #102

@github-actions github-actions bot added the enhancement New features or code improvements label Aug 1, 2023
@codecov-commenter
Copy link

codecov-commenter commented Aug 1, 2023

Codecov Report

Merging #103 (9192c45) into main (c9898a4) will decrease coverage by 0.04%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main     #103      +/-   ##
==========================================
- Coverage   88.75%   88.71%   -0.04%     
==========================================
  Files          11       11              
  Lines        2320     2312       -8     
==========================================
- Hits         2059     2051       -8     
  Misses        261      261              

@lboucin
Copy link
Collaborator Author

lboucin commented Aug 2, 2023

@chrpetre @EDCarman this PR enables multiple python process importing pytwin to run in parallel. Drawback is the pytwin default working directory is no longer cleanup when pytwin is imported. This makes the temp directory can became quite big. User currently has the option to setup an another working directory and we might provide a cleanup_pytwin_default_working_directory helper to clean it up at user request. To be discussed

@lboucin lboucin requested a review from ansJBoly August 2, 2023 07:47
Copy link
Collaborator

@chrpetre chrpetre left a comment

Choose a reason for hiding this comment

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

hi @lboucin
thanks for the PR. That looks good to me. I just have few questions/comments

  • how has the change been tested/validated (e.g. would that make sense to have 1 more unit test ?)
  • should we have an option to cleanup the working directory at the end of the process if possible (and we could put the default to True which would remove all the files at the end of process) ? so that we don't accumulate too much files/data

@lboucin
Copy link
Collaborator Author

lboucin commented Aug 25, 2023

Hello @chrpetre, please find answers below:

  • the PR has been tested/validated interactively. SAF developer tried it and confirmed the issue encountered while importing pytwin in a saf solution is resolved with this PR. Since all unit tests from the test_settings.py are passing and I don't know how to enforce pytest to run on multiple processes, I thought that was enough.
  • I'm not sure how to call such a method just before the python process ends. I will have a look at this but I think it is not a good idea to clean the temp folder automatically, since this might delete some working directory still in used by other python processes. And thus we might even not be able to do so... Alternatively, I would suggest to expose a utility to clean the pytwin temp directory at user request, keeping alive any folder in which some files are used by another process. The idea would be to do the same as when you try to delete all folder from your %TEMP% dir manually and if some file are in used by other process a pop up opens and ask you to choose btw keep the file or retry to delete. I think we can do that without raising the pop up, just keeping any files in the pytwin TEMP folder being in used by another process. If this makes sens, I propose to code it in an other PR. What do you think?

Copy link
Collaborator

@chrpetre chrpetre left a comment

Choose a reason for hiding this comment

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

thanks @lboucin let's follow up separately for the other topic on how to best deal with the management of data accumulated in temp folders

@lboucin lboucin merged commit 3f26221 into main Aug 25, 2023
15 of 20 checks passed
@lboucin lboucin deleted the feat/issue_102 branch August 25, 2023 14:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New features or code improvements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for pytwin import by multiple python processes
4 participants