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

dagster daemon / dev cli does not support python-file option #16029

Open
yuvalgimmunai opened this issue Aug 23, 2023 · 3 comments
Open

dagster daemon / dev cli does not support python-file option #16029

yuvalgimmunai opened this issue Aug 23, 2023 · 3 comments
Labels
type: bug Something isn't working

Comments

@yuvalgimmunai
Copy link
Contributor

Dagster version

1.4.7

What's the issue?

Starting a dagster dev env from daemon / dev cli with --python-file repository is raising an error.

When no port or socket are specific we receive this error

class DagsterGrpcServer:
    def __init__(
        self,
        server_termination_event: threading.Event,
        dagster_api_servicer: DagsterApiServicer,
        host="localhost",
        port: Optional[int] = None,
        socket: Optional[str] = None,
        max_workers: Optional[int] = None,
    ):
        check.invariant(
            port is not None if seven.IS_WINDOWS else True,
            "You must pass a valid `port` on Windows: `socket` not supported.",
        )
        check.invariant(
            (port or socket) and not (port and socket),
            "You must pass one and only one of `port` or `socket`.",
        )
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/Users/yuvalgrinberg/envs/dagster-landing-service/lib/python3.10/site-packages/dagster/__main__.py", line 3, in <module>
    main()
  File "/Users/yuvalgrinberg/envs/dagster-landing-service/lib/python3.10/site-packages/dagster/_cli/__init__.py", line 48, in main
    cli(auto_envvar_prefix=ENV_PREFIX)  # pylint:disable=E1123
  File "/Users/yuvalgrinberg/envs/dagster-landing-service/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/Users/yuvalgrinberg/envs/dagster-landing-service/lib/python3.10/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/Users/yuvalgrinberg/envs/dagster-landing-service/lib/python3.10/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/yuvalgrinberg/envs/dagster-landing-service/lib/python3.10/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/yuvalgrinberg/envs/dagster-landing-service/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/yuvalgrinberg/envs/dagster-landing-service/lib/python3.10/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/Users/yuvalgrinberg/envs/dagster-landing-service/lib/python3.10/site-packages/dagster/_cli/api.py", line 688, in grpc_command
    server = DagsterGrpcServer(
  File "/Users/yuvalgrinberg/envs/dagster-landing-service/lib/python3.10/site-packages/dagster/_grpc/server.py", line 947, in __init__
    check.invariant(
  File "/Users/yuvalgrinberg/envs/dagster-landing-service/lib/python3.10/site-packages/dagster/_check/__init__.py", line 1589, in invariant
    raise CheckError(f"Invariant failed. Description: {desc}")
dagster._check.CheckError: Invariant failed. Description: You must pass one and only one of `port` or `socket`.

And if we try to provide the port, we get the following error:

def get_workspace_load_target(kwargs: ClickArgMapping) -> WorkspaceLoadTarget:
    check.mapping_param(kwargs, "kwargs")
    
    ...
    
    if kwargs.get("python_file"):
        _check_cli_arguments_none(
            kwargs,
            "module_name",
            "package_name",
            "grpc_host",
            "grpc_port",
            "grpc_socket",
        )
        python_files = kwargs["python_file"]
Usage: python -m dagster._daemon run [OPTIONS]
Try 'python -m dagster._daemon run --help' for help.

Error: Invalid set of CLI arguments for loading repository/job. See --help for details.

What did you expect to happen?

To be able to run a dagster local env while loading the repository from the --python-file

How to reproduce?

dagster-daemon run --python-file PATH_TO_REPO_FILE --grpc-port 3000

dagster-daemon run --python-file PATH_TO_REPO_FILE

Deployment type

Local

Deployment details

No response

Additional information

No response

Message from the maintainers

Impacted by this issue? Give it a 👍! We factor engagement into prioritization.

@yuvalgimmunai yuvalgimmunai added the type: bug Something isn't working label Aug 23, 2023
@alangenfeld
Copy link
Member

Starting a dagster dev env from daemon / dev cli with --python-file repository is raising an error.
When no port or socket are specific we receive this error

What CLI command did you run here exactly? dagster dev --python-file ... should work just fine.

dagster-daemon run --python-file PATH_TO_REPO_FILE --grpc-port 3000

The --python-file and --grpc-port flags are conflicting. --python-file instructs the daemon to boot a grpc code server for the code located at the target directory. --grpc-port instructs the daemon to connect to an existing grpc code server via the specified port.

@gibsondan
Copy link
Member

gibsondan commented Aug 23, 2023

This turned out to be DAGSTER_GRPC_PORT being set in a .env file - it was getting picked up as a click arg while also being passed a socket from the parent process

Easy repro:

DAGSTER_GRPC_PORT=4000 dagster dev -f hi.py

@gibsondan
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants