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

InstalledCode and PortableCode pydantic models emit serialization warnings #6364

Open
danielhollas opened this issue Apr 21, 2024 · 1 comment
Labels

Comments

@danielhollas
Copy link
Collaborator

Describe the bug

I noticed a couple of warnings / errors in the nightly tests log (in "Setup environment" step), not sure if those are pertinent to anything, see full log

/opt/hostedtoolcache/Python/3.10.14/x64/lib/python3.10/site-packages/pydantic/main.py:308: UserWarning: Pydantic serializer warnings:
  Expected `str` but got `Computer` - serialized value may not be as expected
  return self.__pydantic_serializer__.to_python(
Opening connection... Error: Error connecting to 'localhost' through SSH: [SshTransport] [Errno None] Unable to connect to port 5001 on 127.0.0.1 or ::1, connect_args were: {'username': 'xenon', 'port': 5001, 'look_for_keys': True, 'key_filename': '/home/runner/.ssh/slurm_rsa', 'timeout': 60, 'allow_agent': True, 'proxy_jump': '', 'proxy_command': '', 'compress': True, 'gss_auth': False, 'gss_kex': False, 'gss_deleg_creds': False, 'gss_host': 'localhost'}
[FAILED]: Error while trying to connect to the computer
  Full traceback:
  Traceback (most recent call last):
    File "/home/runner/work/aiida-core/aiida-core/src/aiida/cmdline/commands/cmd_computer.py", line 542, in computer_test
      with transport:
    File "/home/runner/work/aiida-core/aiida-core/src/aiida/transports/transport.py", line 129, in __enter__
      self.open()
    File "/home/runner/work/aiida-core/aiida-core/src/aiida/transports/plugins/ssh.py", line 498, in open
      self._client.connect(self._machine, **connection_arguments)
    File "/opt/hostedtoolcache/Python/3.10.14/x64/lib/python3.10/site-packages/paramiko/client.py", line 381, in connect
      raise NoValidConnectionsError(errors)
  paramiko.ssh_exception.NoValidConnectionsError: [Errno None] Unable to connect to port 5001 on 127.0.0.1 or ::1
Warning: 1 out of 0 tests failed
@sphuber sphuber changed the title Warnings / errors in nightly tests InstalledCode and PortableCode pydantic models emit serialization warnings Apr 28, 2024
@sphuber
Copy link
Contributor

sphuber commented Apr 28, 2024

The SSH error was handled in #6372 and was not really of any consequence.

I have renamed the issue to reflect the maining issue which is separate. Essentially, the mentioned code models declare the fields computer and filepath_file, with the types str. However, they have a serializer that converts them to a Computer instance and a pathlib.Path instance. This is allowed by pydantic but it does warn that the return type of the custom serializer does not match the type declaration. The reason for the type change is that the return type is easier to deal with in the Python API, so it is convenience for the user. I think I only added a single type instead of a Union because the dynamic CLI verdi code create needs to determine the option type based on the type annotation and click does not support unions, so it has to choose one, which currently emits a warning as well. But I guess we can simply silence this warning.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants