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

Use of reduce without initializers in asset_selection.py #27113

Open
axellpadilla opened this issue Jan 15, 2025 · 0 comments
Open

Use of reduce without initializers in asset_selection.py #27113

axellpadilla opened this issue Jan 15, 2025 · 0 comments
Labels
type: bug Something isn't working

Comments

@axellpadilla
Copy link
Contributor

What's the issue?

There are multiple occurrences of reduce being used without an initializer in dagster/python_modules/dagster/dagster/_core/definitions/asset_selection.py.
This can cause an error when an empty selection is used, I had some instances when using for example job_def.selection.resolve where I needed to manually fix this.

TypeError( "reduce() of empty iterable with no initial value")

For example:

reduce(
operator.or_,
[
{asset_key}
| fetch_connected(
item=asset_key,
graph=asset_graph.asset_dep_graph,
direction="downstream",
depth=self.depth,
)
for asset_key in selection
],
),
)

This should be modified to include an initializer to prevent errors with empty sequences:

Expected use:

reduce(
operator.or_,
[
{asset_key}
| fetch_connected(
item=asset_key,
graph=asset_graph.asset_dep_graph,
direction="upstream",
depth=depth,
)
for asset_key in selection
],
set(),
),

What did you expect to happen?

Empty set result like expected use:

reduce(
operator.or_,
[
{asset_key}
| fetch_connected(
item=asset_key,
graph=asset_graph.asset_dep_graph,
direction="upstream",
depth=depth,
)
for asset_key in selection
],
set(),
),

How to reproduce?

Any selection resolved to empty set.

Dagster version

1.9.6

Deployment type

None

Deployment details

No response

Additional information

No response

Message from the maintainers

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

@axellpadilla axellpadilla added the type: bug Something isn't working label Jan 15, 2025
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

1 participant