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

Engine: Fix bug in upload calculation for PortableCode with SSH #6519

Merged

Conversation

sphuber
Copy link
Contributor

@sphuber sphuber commented Jul 4, 2024

Fixes #6518

When a CalcJob would be run with a PortableCode using a computer configured with the core.ssh transport plugin, the upload task would except. The aiida.engine.daemon.execmanager.upload_calculation method is passing pathlib.Path objects to the transport interface which is not supported. By chance this does not raise an exception when using the LocalTransport, but the SshTransport passes these values to the paramiko library which does choke on anything but strings.

The use of a PortableCode was tested for in the unit test tests/engine/processes/calcjobs/test_calc_job.py:test_portable_code but this would only use a local transport and thus the bug would not appear. Parametrizing it to also use the SshTransport wouldn't help since the test uses metadata.dry_run = True, whose implementation will always swap the transport to a local one, still avoiding the bugged code pathway.

Instead a test is added that directly calls upload_calculation which parametrizes over all installed transport plugins and uses a PortableCode. This confirmed the bug. The upload_calculation method is updated to ensure casting all pathlib.Path objects to str before passing it to the transport.

When a `CalcJob` would be run with a `PortableCode` using a computer
configured with the `core.ssh` transport plugin, the upload task would
except. The `aiida.engine.daemon.execmanager.upload_calculation` method
is passing `pathlib.Path` objects to the transport interface which is
not supported. By chance this does not raise an exception when using the
`LocalTransport`, but the `SshTransport` passes these values to the
paramiko library which does choke on anything but strings.

The use of a `PortableCode` was tested for in the unit test
`tests/engine/processes/calcjobs/test_calc_job.py:test_portable_code`
but this would only use a local transport and thus the bug would not
appear. Parametrizing it to also use the `SshTransport` wouldn't help
since the test uses `metadata.dry_run = True`, whose implementation will
always swap the transport to a local one, still avoiding the bugged
code pathway.

Instead a test is added that directly calls `upload_calculation` which
parametrizes over all installed transport plugins and uses a
`PortableCode`. This confirmed the bug. The `upload_calculation` method
is updated to ensure casting all `pathlib.Path` objects to `str` before
passing it to the transport.
@sphuber sphuber requested a review from GeigerJ2 July 4, 2024 16:25
Copy link

codecov bot commented Jul 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 77.79%. Comparing base (ef60b66) to head (e738c1c).
Report is 115 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6519      +/-   ##
==========================================
+ Coverage   77.51%   77.79%   +0.29%     
==========================================
  Files         560      561       +1     
  Lines       41444    41820     +376     
==========================================
+ Hits        32120    32530     +410     
+ Misses       9324     9290      -34     

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

@sphuber sphuber merged commit f992443 into aiidateam:main Jul 5, 2024
11 checks passed
@sphuber sphuber deleted the fix/6518/portable-code-ssh-transport branch July 5, 2024 07:00
sphuber added a commit that referenced this pull request Aug 7, 2024
)

When a `CalcJob` would be run with a `PortableCode` using a computer
configured with the `core.ssh` transport plugin, the upload task would
except. The `aiida.engine.daemon.execmanager.upload_calculation` method
is passing `pathlib.Path` objects to the transport interface which is
not supported. By chance this does not raise an exception when using the
`LocalTransport`, but the `SshTransport` passes these values to the
paramiko library which does choke on anything but strings.

The use of a `PortableCode` was tested for in the unit test
`tests/engine/processes/calcjobs/test_calc_job.py:test_portable_code`
but this would only use a local transport and thus the bug would not
appear. Parametrizing it to also use the `SshTransport` wouldn't help
since the test uses `metadata.dry_run = True`, whose implementation will
always swap the transport to a local one, still avoiding the bugged
code pathway.

Instead a test is added that directly calls `upload_calculation` which
parametrizes over all installed transport plugins and uses a
`PortableCode`. This confirmed the bug. The `upload_calculation` method
is updated to ensure casting all `pathlib.Path` objects to `str` before
passing it to the transport.

Cherry-pick: f992443
mikibonacci pushed a commit to mikibonacci/aiida-core that referenced this pull request Sep 3, 2024
…idateam#6519)

When a `CalcJob` would be run with a `PortableCode` using a computer
configured with the `core.ssh` transport plugin, the upload task would
except. The `aiida.engine.daemon.execmanager.upload_calculation` method
is passing `pathlib.Path` objects to the transport interface which is
not supported. By chance this does not raise an exception when using the
`LocalTransport`, but the `SshTransport` passes these values to the
paramiko library which does choke on anything but strings.

The use of a `PortableCode` was tested for in the unit test
`tests/engine/processes/calcjobs/test_calc_job.py:test_portable_code`
but this would only use a local transport and thus the bug would not
appear. Parametrizing it to also use the `SshTransport` wouldn't help
since the test uses `metadata.dry_run = True`, whose implementation will
always swap the transport to a local one, still avoiding the bugged
code pathway.

Instead a test is added that directly calls `upload_calculation` which
parametrizes over all installed transport plugins and uses a
`PortableCode`. This confirmed the bug. The `upload_calculation` method
is updated to ensure casting all `pathlib.Path` objects to `str` before
passing it to the transport.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants