Skip to content
This repository has been archived by the owner on Jul 3, 2023. It is now read-only.

Tag outputs #256

Merged
merged 1 commit into from
Dec 23, 2022
Merged

Tag outputs #256

merged 1 commit into from
Dec 23, 2022

Conversation

elijahbenizzy
Copy link
Collaborator

See #254

@elijahbenizzy elijahbenizzy changed the base branch from main to subdag-modifier-rebase December 23, 2022 04:01
@skrawcz
Copy link
Collaborator

skrawcz commented Dec 23, 2022

Need a commit message that informs of design decisions please.

Copy link
Collaborator

@skrawcz skrawcz left a comment

Choose a reason for hiding this comment

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

Do we need tag_nodes to handle the "all case"? Why not just double up on decorators?

hamilton/function_modifiers/metadata.py Outdated Show resolved Hide resolved
hamilton/function_modifiers/metadata.py Outdated Show resolved Hide resolved
hamilton/function_modifiers/metadata.py Outdated Show resolved Hide resolved
hamilton/function_modifiers/metadata.py Outdated Show resolved Hide resolved
hamilton/function_modifiers/metadata.py Outdated Show resolved Hide resolved
@elijahbenizzy elijahbenizzy force-pushed the tag_nodes branch 5 times, most recently from d7e3398 to 5c9f8ba Compare December 23, 2022 18:07
@skrawcz skrawcz changed the title Tag nodes Tag outputs Dec 23, 2022
Copy link
Collaborator

@skrawcz skrawcz left a comment

Choose a reason for hiding this comment

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

Just some docs tuning, otherwise looks good!

decorators.md Outdated
### @tag_outputs

`tag_outputs` enables you to attach metadata to a function that outputs multiple nodes,
and give different tag values to different items:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
and give different tag values to different items:
and give different tag values to different outputs:

items isn't a term we use.

decorators.md Outdated Show resolved Hide resolved
decorators.md Outdated
## @tag
## @tag and friends

### @tag

Allows you to attach metadata to a node (any node decorated with the function).
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
Allows you to attach metadata to a node (any node decorated with the function).
Allows you to attach metadata to an output(s), i.e. all nodes generated by a function and its decorators.

decorators.md Outdated Show resolved Hide resolved
decorators.md Outdated
Comment on lines 365 to 374
@extract_columns('public', 'private')
def data_used_in_multiple_ways() -> pd.DataFrame:
return load_some_data(...)
```

In the case above, `common_tag` would resolve to `foo` for `public` and `bar` for `private`.
Attempting an override in the reverse direction is currently undefined behavior.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
@extract_columns('public', 'private')
def data_used_in_multiple_ways() -> pd.DataFrame:
return load_some_data(...)
```
In the case above, `common_tag` would resolve to `foo` for `public` and `bar` for `private`.
Attempting an override in the reverse direction is currently undefined behavior.
@extract_columns('column_a', 'column_b')
def data_used_in_multiple_ways() -> pd.DataFrame:
return load_some_data(...)
```
In the case above, `common_tag` would resolve to `foo` for `column_a` and `bar` for `column_b`.
Attempting an override in the reverse direction is currently undefined behavior.

Solves #254

`tag_outputs` enables you to attach metadata to a function that outputs
multiple nodes, and give different tag values to different items.

This can be applied multiple times, and precedence order of the `tag`
family of nodes is in reverse application order (see docs). Note that
if we have `tag` before `tag_outputs` this is undefined behavior.
@elijahbenizzy elijahbenizzy merged commit 1890cad into subdag-modifier-rebase Dec 23, 2022
@elijahbenizzy elijahbenizzy deleted the tag_nodes branch December 23, 2022 18:32
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants