Closed BishopWolf closed 3 months ago
Excellent, thanks! However, I got: AttributeError: module 'os' has no attribute 'mkdirs' maybe makedirs ?
Excellent, thanks! However, I got: AttributeError: module 'os' has no attribute 'mkdirs' maybe makedirs ?
I have changed some os calls by pathlib. This is very easy to maintain as all OS related specificities are automatically handled.
I am solving all errors caught by the tests
There are still places expecting string paths instead of path objects. As a rule, you can't pass strings to methods expecting paths, as it's very difficult to maintain. This is why pathlib is preferred. Example:
path1 = "/some/path"
path2 = "/some/path/"
# adding a file pathlib way
file1 = Path(path1) / "myfile"
file2 = Path(path2) / "myfile"
assert(str(file1) == str(file2)) # returns true
# os way
file1 = os.path.join(path1, "myfile")
file2 = os.path.join(path2, "myfile")
assert(file1== file2) # returns false
# file1 is "/some/path/myfile" in Nix and "/some/path\myfile" in Windows
# file2 is "/some/path//myfile" in Nix and "/some/path/\myfile" in Windows
I see some merge conflicts with the last pull in wget. @tbaudier may you please review?
The only error remaining in test040_gan_phsp_pet_gan.py
File "/opt/hostedtoolcache/Python/3.11.9/x64/lib/python3.11/site-packages/opengate/actors/arfactors.py", line 243, in apply_with_lock
w = self.garf.nn_predict(self.model, self.nn["model_data"], ax)
^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'garf' has no attribute 'nn_predict'
@tbaudier : all tests are passing now
@tbaudier : my tests didn't show any errors, see https://github.com/BishopWolf/opengate/actions/runs/10093731109/job/27911347164
Something is weird
@tbaudier : my tests didn't show any errors, see https://github.com/BishopWolf/opengate/actions/runs/10093731109/job/27911347164
Something is weird
I will look at your PR, I think it's due to the rebasing of the branch. Do not modify it for the moment and I will try to do the necessary. Thomas
This error is because filename shall be Path:
File "/opt/hostedtoolcache/Python/3.11.9/x64/lib/python3.11/site-packages/opengate/engines.py", line 612, in stop_simulation
actor.EndSimulationAction()
File "/opt/hostedtoolcache/Python/3.11.9/x64/lib/python3.11/site-packages/opengate/actors/miscactors.py", line 126, in EndSimulationAction
self.write(self.user_info.output)
File "/opt/hostedtoolcache/Python/3.11.9/x64/lib/python3.11/site-packages/opengate/actors/miscactors.py", line 146, in write
with filename.open("w") as f:
^^^^^^^^^^^^^
AttributeError: 'str' object has no attribute 'open'
But it's being called by
and user_info.output is just a filename string without path
This PR fixes fresh installations errors when parent folders are not created by default giving
These errors were triggered by some tests and are all solved by this PR. The change ensures the folders AND all their parents are created.