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

[cli-refactor] Type and validate python_pointer_opts at entry point #27501

Merged
merged 1 commit into from
Feb 3, 2025

Conversation

smackesey
Copy link
Collaborator

@smackesey smackesey commented Feb 3, 2025

Summary & Motivation

First PR in the stack that replaces passing around "kwargs" with entry point validation and typing.

  • Add a PythonPointerOpts value object corresponding to the @python_pointer_opts decorator.
  • Wherever @python_pointer_opts is used:
    • Immediately parse the untyped bag of cli_opts into a PythonPointerOpts object.
    • Generally clean up the signatures of the targeted click commands, ensuring all other opts are passed as arguments instead of inside the generic bag of CLI opts.

How I Tested These Changes

Existing test suite.

container_context: Optional[str] = None,
location_name: Optional[str] = None,
instance_ref=None,
inject_env_vars_from_instance: bool = False,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

These defaults are unnecessary and misleading-- click will always call the function with values for all args, so no default is ever used.

@smackesey smackesey changed the base branch from sean/workspace/consolidate-job-target to graphite-base/27501 February 3, 2025 13:52
@smackesey smackesey force-pushed the graphite-base/27501 branch from 5d7ae2e to 5ab09e4 Compare February 3, 2025 13:59
@smackesey smackesey force-pushed the sean/workspace/python-pointer-opts branch from a82982f to 2e6cb01 Compare February 3, 2025 13:59
@smackesey smackesey force-pushed the graphite-base/27501 branch from 5ab09e4 to a58be30 Compare February 3, 2025 14:39
@smackesey smackesey force-pushed the sean/workspace/python-pointer-opts branch from 2e6cb01 to ed80169 Compare February 3, 2025 14:39
) -> None:
python_pointer_opts = PythonPointerOpts.extract_from_cli_options(other_opts)
assert_no_remaining_opts(other_opts)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

assert_no_remaining_opts ensures we didn't forget to list any other options in the signature-- all options are accounted for by either being explicitly listed, or extracted from the other_opts dict into a typed object.

@smackesey smackesey force-pushed the sean/workspace/python-pointer-opts branch 3 times, most recently from 7563e7b to 83a1ae9 Compare February 3, 2025 16:38
@smackesey smackesey force-pushed the graphite-base/27501 branch from a58be30 to 9c0b023 Compare February 3, 2025 16:39
@smackesey smackesey marked this pull request as ready for review February 3, 2025 17:32
@smackesey smackesey requested a review from schrockn February 3, 2025 17:33
@smackesey smackesey force-pushed the graphite-base/27501 branch from 9c0b023 to 0b89790 Compare February 3, 2025 17:35
@smackesey smackesey force-pushed the sean/workspace/python-pointer-opts branch 2 times, most recently from 0ae237a to cfd3e5d Compare February 3, 2025 18:43
@smackesey smackesey force-pushed the graphite-base/27501 branch from 0b89790 to 97522d5 Compare February 3, 2025 18:43
Copy link
Collaborator Author

smackesey commented Feb 3, 2025

Merge activity

  • Feb 3, 6:19 PM EST: A user started a stack merge that includes this pull request via Graphite.
  • Feb 3, 6:23 PM EST: Graphite rebased this pull request as part of a merge.
  • Feb 3, 6:24 PM EST: A user merged this pull request with Graphite.

@smackesey smackesey changed the base branch from graphite-base/27501 to master February 3, 2025 23:20
@smackesey smackesey force-pushed the sean/workspace/python-pointer-opts branch from cfd3e5d to 6658a41 Compare February 3, 2025 23:22
@smackesey smackesey merged commit ed16fee into master Feb 3, 2025
4 of 5 checks passed
@smackesey smackesey deleted the sean/workspace/python-pointer-opts branch February 3, 2025 23:24
benpankow added a commit that referenced this pull request Feb 4, 2025
## Summary

#27501 introduced a change where we must pass the working directory to
`dagster assets materialize` - adds that to our dg docs tests
smackesey added a commit that referenced this pull request Feb 4, 2025
#27559)

## Summary & Motivation

#27501 introduced a regression in setting the working directory of code
pointers correctly for certain entry points-- this fixes it.

## How I Tested These Changes

Docs beta snippet that was failing now passes.
prha pushed a commit that referenced this pull request Feb 5, 2025
#27559)

## Summary & Motivation

#27501 introduced a regression in setting the working directory of code
pointers correctly for certain entry points-- this fixes it.

## How I Tested These Changes

Docs beta snippet that was failing now passes.
smackesey added a commit that referenced this pull request Feb 10, 2025
## Summary & Motivation

#27501 added typing and validation of args for all CLI entry points that
accept a "python pointer" (i.e. pointer to a single code location). This
PR continues that theme for all commands that accept a workspace
specification.

All commands that operate on a workspace now immediately parse passed
workspace-specifyng options into the new typed `WorkspaceOpts` object.
All these commands have also had their signatures cleaned up. Many of
the helper methods used within these commands (which previously operated
on untyped bags of "kwargs") have also been refactored.

## How I Tested These Changes

Existing test suite (with some refactors to handle new `WorkspaceOpts`).
LoHertel pushed a commit to LoHertel/dagster that referenced this pull request Feb 11, 2025
…agster-io#27501)

## Summary & Motivation

First PR in the stack that replaces passing around "kwargs" with entry point validation and typing.

- Add a `PythonPointerOpts` value object corresponding to the `@python_pointer_opts` decorator.
- Wherever `@python_pointer_opts` is used:
     - Immediately parse the untyped bag of cli_opts into a `PythonPointerOpts` object.
     - Generally clean up the signatures of the targeted click commands, ensuring all other opts are passed as arguments instead of inside the generic bag of CLI opts.

## How I Tested These Changes

Existing test suite.
LoHertel pushed a commit to LoHertel/dagster that referenced this pull request Feb 11, 2025
## Summary

dagster-io#27501 introduced a change where we must pass the working directory to
`dagster assets materialize` - adds that to our dg docs tests
LoHertel pushed a commit to LoHertel/dagster that referenced this pull request Feb 11, 2025
dagster-io#27559)

## Summary & Motivation

dagster-io#27501 introduced a regression in setting the working directory of code
pointers correctly for certain entry points-- this fixes it.

## How I Tested These Changes

Docs beta snippet that was failing now passes.
LoHertel pushed a commit to LoHertel/dagster that referenced this pull request Feb 11, 2025
…er-io#27540)

## Summary & Motivation

dagster-io#27501 added typing and validation of args for all CLI entry points that
accept a "python pointer" (i.e. pointer to a single code location). This
PR continues that theme for all commands that accept a workspace
specification.

All commands that operate on a workspace now immediately parse passed
workspace-specifyng options into the new typed `WorkspaceOpts` object.
All these commands have also had their signatures cleaned up. Many of
the helper methods used within these commands (which previously operated
on untyped bags of "kwargs") have also been refactored.

## How I Tested These Changes

Existing test suite (with some refactors to handle new `WorkspaceOpts`).
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