Repository navigation
Remove os.chdir() method; add support for other key_file types other than RSA - #275
Conversation
* add wait_time for resubmitted * fix the generation of empty logfile
* add script rendering test for each part
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #275 +/- ##
==========================================
+ Coverage 59.44% 59.83% +0.39%
==========================================
Files 27 27
Lines 2895 2846 -49
==========================================
- Hits 1721 1703 -18
+ Misses 1174 1143 -31 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| ]: | ||
| for directory in [".ssh", "ssh"]: | ||
| full_path = os.path.expanduser( | ||
| "~/{}/id_{}".format(directory, name) |
There was a problem hiding this comment.
This breaks the compatibility on the Windows platform. Use os.path.join or Pathlib instead.
There was a problem hiding this comment.
os.path.expanduser is just a Windows compatible implementation while add ssh in loop is an official implementation from paramiko.
There was a problem hiding this comment.
This is my result on Windows:
PS C:\Program Files\Microsoft Visual Studio\2022\Community> python.exe
Python 3.10.8 (tags/v3.10.8:aaaf517, Oct 11 2022, 16:50:30) [MSC v.1933 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.path.expanduser("~/.ssh/id_rsa")
'C:\\Users\\njzjz/.ssh/id_rsa'The correct output should be 'C:\\Users\\njzjz\\.ssh\\id_rsa'.
There was a problem hiding this comment.
OK, I understand. Using pathlib might be a better choice.
For what has been mentioned in the WeChat Group, it is in need to support not only the RSA type key and thus it is add in this PR.
Also, I found unexpected
cwdchange in a dpdispatcher submission, which could be OK when tasks submitted in serial, whosecwdis just the same for each single task. However, it might be a severe bug when tasks submitted in a parallel way, which might result in single task that just start in a WRONGwork_pathand thus it could not find the files in the right place. For some workflow management system (such as prefect), the bug was observed.While in the former implementation,
os.chdir()is only used in 3 situations. Foros.symlink(), it seemsdpdispatcherjust not using relevant path so there is no need to changecwd. Fortarfile.add(),abspathcould be used to find the file while usingarcnameparameter could recover the relevant path in the tar file. Forsubprocess.Popen(), itscwdparameter is just the key to the door. So with justos.pathdealing with the relevant path in the code, we could just dropos.chdir()out to makecwdnot change in a python run.The changed way is test to be OK in the Unittests and cluster environment for
LocalContextandSSHContext. However, I am not sure whether it would be OK forBohriumand more tests might be in need.