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

TypeError: SSHClientConfig.__init__() missing 2 required positional args #99

Open
wants to merge 16 commits into
base: main
Choose a base branch
from

Conversation

99-NinetyNine
Copy link

Issue fixed :

while doing dvc pull or push, there was error. mainly due to the updated library code for ssh.
TypeError: SSHClientConfig.init() missing 2 required positional arguments: 'host' and 'port'

image
The library function that causes exception is this.

@shcheklein
Copy link
Member

it seems to be still broken

@99-NinetyNine
Copy link
Author

I tried changing those params, my prod setup worked.
however, test cases are failing.

this issue may be due to drastic changes in assync ssh library. some test cases might have to be revised.

Copy link
Member

@shcheklein shcheklein left a comment

Choose a reason for hiding this comment

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

thanks for the research @99-NinetyNine . what is the change in parse_config? you can do a PR in sshfs (I can approve and merge in both repos).

@99-NinetyNine
Copy link
Author

Actually,

  1. asyncssh has load() method,
    image
    which passes *args to cls to create new object, but init has host, port as required parameters.
    That is, five arguments are necessary, rest are handled in *.

  2. But, sshfs config.py parse method has
    image
    Issue, is host and port are not passed one to one since due to canonical variable is there. So we can solve by passing key=value in the sshfa config.py parse_config method.

And I simply updated that parse_config and attached in dvc_ssh as a quick fix.

The new pull request in sshfs repo is created by me, with updated parse config is also created. After this, dvc_ssh needs no changes.

@99-NinetyNine
Copy link
Author

99-NinetyNine commented Jan 7, 2025

I could not find sshfs github repo,
///////////////////////////////////////////////////////////////
// config/parse_config.py should be like this////
////////////////////////////////////////////////////////////////

import getpass
from contextlib import suppress
from pathlib import Path, PurePath
from typing import Sequence, Union
from asyncssh.config import SSHClientConfig

SSH_CONFIG = Path("~", ".ssh", "config").expanduser()
FilePath = Union[str, PurePath]
def parse_config(
    *, host, user=(), port=(), local_user=None, config_files=None
):
    if config_files is None:
        config_files = [SSH_CONFIG]

    if local_user is None:
        with suppress(KeyError):
            local_user = getpass.getuser()

    last_config = None
    reload = False
    config = SSHClientConfig(
        last_config =last_config,
        reload = reload,
        canonical = False,
        final=False,
        local_user = local_user,
        user = user,
        host = host,
        port = port,
    )

    if config_files:
        if isinstance(config_files, (str, PurePath)):
            paths: Sequence[FilePath] = [config_files]
        else:
            paths = config_files

        for path in paths:
            config.parse(Path(path))
        config.loaded = True
    return config

@shcheklein
Copy link
Member

@99-NinetyNine fsspec/sshfs#55 - here is the repo

btw, here is the relevant discussion fsspec/sshfs#54

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

Successfully merging this pull request may close these issues.

2 participants