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

Make all ExtClients plain-ole-python objects #16352

Merged
merged 4 commits into from
Sep 7, 2023
Merged

Conversation

schrockn
Copy link
Member

@schrockn schrockn commented Sep 6, 2023

Summary & Motivation

Making this class hierarchy not inherit from ConfigurableResource. To avoid forcing users from using ResourceParam, with every use, I am proposing a pattern where we export the annotated type. We could support this more directly and ergonomically in the framework, but I think this the user-facing behavior we want for ext users.

How I Tested These Changes

BK

@schrockn
Copy link
Member Author

schrockn commented Sep 6, 2023

@@ -88,3 +84,6 @@ def _setup_io(
message_reader.read_messages(external_context)
)
yield io_params_as_env_vars(context_injector_params, message_reader_params)


ExtSubprocess = ResourceParam[_ExtSubprocess]
Copy link
Member Author

@schrockn schrockn Sep 6, 2023

Choose a reason for hiding this comment

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

@benpankow wanted to flag this. I think this is a way to avoid forcing people from doing ResourceParam everywhere. We could probably support this directly with a marker interface or something, but this was easy for now.

Copy link
Member

Choose a reason for hiding this comment

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

This seems reasonable to me and is a neat pattern - I wonder if this sort of approach could help in cases where folks are using ResourceParam right now. Maybe if they re-use the same POPO in various places...?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah I guess I couldn't write this in docs without feeling embarassed about it. It is very counterintuitive at first glance.

Copy link
Collaborator

@smackesey smackesey left a comment

Choose a reason for hiding this comment

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

makes sense

class _ExtSubprocess(ExtClient):
def __init__(self, env: Optional[Mapping[str, str]] = None, cwd: Optional[str] = None):
self.env = check.opt_mapping_param(env, "env", key_type=str, value_type=str)
self.cwd = check.opt_str_param(cwd, "cwd")
Copy link
Collaborator

Choose a reason for hiding this comment

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

[1] Can we retain the param descriptions in a docstring

self, env: Optional[Mapping[str, str]] = None, registry: Optional[Mapping[str, str]] = None
):
self.env = check.opt_mapping_param(env, "env", key_type=str, value_type=str)
self.registry = check.opt_mapping_param(registry, "registry", key_type=str, value_type=str)
Copy link
Collaborator

Choose a reason for hiding this comment

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

[1]

description="An optional dict of environment variables to set on the container.",
)
def __init__(self, env: Optional[Mapping[str, str]] = None):
self.env = check.opt_mapping_param(env, "env", key_type=str, value_type=str)
Copy link
Collaborator

Choose a reason for hiding this comment

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

[1]

@schrockn
Copy link
Member Author

schrockn commented Sep 7, 2023

Merge Activity

  • Sep 7, 12:34 PM: @schrockn started a stack merge that includes this pull request via Graphite.
  • Sep 7, 12:34 PM: Graphite rebased this pull request as part of a merge.
  • Sep 7, 12:35 PM: @schrockn merged this pull request with Graphite.

Base automatically changed from make-clients-POPO-1 to master September 7, 2023 16:34
@schrockn schrockn merged commit 6158437 into master Sep 7, 2023
1 check was pending
@schrockn schrockn deleted the make-clients-POPO-2 branch September 7, 2023 16:35
zyd14 pushed a commit to zyd14/dagster that referenced this pull request Sep 15, 2023
## Summary & Motivation

Making this class hierarchy not inherit from `ConfigurableResource`. To avoid forcing users from using `ResourceParam`, with every use, I am proposing a pattern where we export the annotated type. We could support this more directly and ergonomically in the framework, but I think this the user-facing behavior we want for ext users.

## How I Tested These Changes

BK
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.

3 participants