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

Pass loading context through _blocking_batch_load #25377

Merged
merged 3 commits into from
Oct 22, 2024

Conversation

briantu
Copy link
Contributor

@briantu briantu commented Oct 18, 2024

Summary & Motivation

This lets us use the loading_context for get_asset_status_cache_values, which saves us from needing to re-fetch the asset records in here again.

Copied from demo PR #25270

How I Tested These Changes

Perf test before/after

pytest python_modules/dagster/dagster_tests/definitions_tests/declarative_automation_tests/perf_tests/test_perf.py

@briantu briantu marked this pull request as ready for review October 18, 2024 20:54
@briantu briantu requested a review from OwenKephart October 18, 2024 20:55
@briantu briantu force-pushed the briantu/make-compute-subset-async branch from 206d74c to 9291fd1 Compare October 18, 2024 22:49
@briantu briantu force-pushed the briantu/pass-loading-context-in-batch branch from 47d27bd to 18a7084 Compare October 18, 2024 22:49
@briantu briantu force-pushed the briantu/make-compute-subset-async branch from 9291fd1 to 9be1378 Compare October 18, 2024 23:03
@briantu briantu force-pushed the briantu/pass-loading-context-in-batch branch from 18a7084 to c6bd3cd Compare October 18, 2024 23:03
@briantu briantu requested a review from alangenfeld October 21, 2024 16:09
@briantu briantu force-pushed the briantu/make-compute-subset-async branch from 9be1378 to 4a1a5a3 Compare October 21, 2024 16:41
@briantu briantu force-pushed the briantu/pass-loading-context-in-batch branch from c6bd3cd to 2e65c08 Compare October 21, 2024 16:41
python_modules/dagster/dagster/_core/loader.py Outdated Show resolved Hide resolved
if not issubclass(ttype, InstanceLoadableBy):
check.failed(f"{ttype} is not Loadable")

batch_load_fn = partial(ttype._batch_load, instance=self.instance) # noqa
blocking_batch_load_fn = partial(ttype._blocking_batch_load, instance=self.instance) # noqa
Copy link
Member

Choose a reason for hiding this comment

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

when I first set this up I imagined we might have other _X_LoadableBy which would bind _X_ instead of the instance for fetching, so in this case ContextLoadableBy

i'm not sure that having different flavors is necessary in the end here - but we might want to drop the Instance part of the naming for LoadableBy interface if we just want to always pass the context

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah my thinking was that in a world where there are multiple things that we want to load with (i.e. multiple Xs), there would likely conceivably be singular objects that would want more than one of those Xs, and so at that point we'd probably just do this change anyway.

Agree LoadableBy would be a better name (maybe that could be a followup to this PR?)

Copy link
Member

Choose a reason for hiding this comment

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

follow up or in this PR is fine with me

@briantu briantu force-pushed the briantu/make-compute-subset-async branch from 4a1a5a3 to 0535e53 Compare October 21, 2024 19:52
@briantu briantu force-pushed the briantu/pass-loading-context-in-batch branch from 2e65c08 to e66b775 Compare October 21, 2024 19:52
@briantu briantu force-pushed the briantu/make-compute-subset-async branch from 0535e53 to 647eb5d Compare October 21, 2024 22:00
@briantu briantu force-pushed the briantu/pass-loading-context-in-batch branch from e66b775 to f4fdc53 Compare October 21, 2024 22:00
@briantu briantu force-pushed the briantu/make-compute-subset-async branch from 8721e6e to 6963946 Compare October 22, 2024 00:45
@briantu briantu force-pushed the briantu/pass-loading-context-in-batch branch from 161dd6c to f9ba80d Compare October 22, 2024 00:45
python_modules/dagster/dagster/_core/loader.py Outdated Show resolved Hide resolved
if not issubclass(ttype, InstanceLoadableBy):
check.failed(f"{ttype} is not Loadable")

batch_load_fn = partial(ttype._batch_load, instance=self.instance) # noqa
blocking_batch_load_fn = partial(ttype._blocking_batch_load, instance=self.instance) # noqa
Copy link
Member

Choose a reason for hiding this comment

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

follow up or in this PR is fine with me

@briantu briantu force-pushed the briantu/make-compute-subset-async branch from 6963946 to 34ba726 Compare October 22, 2024 19:39
@briantu briantu force-pushed the briantu/pass-loading-context-in-batch branch from f9ba80d to 3643d67 Compare October 22, 2024 19:39
@briantu briantu force-pushed the briantu/make-compute-subset-async branch from b0837ff to 6e4b0df Compare October 22, 2024 20:24
@briantu briantu force-pushed the briantu/pass-loading-context-in-batch branch from 3643d67 to 51882eb Compare October 22, 2024 20:24
@briantu briantu force-pushed the briantu/make-compute-subset-async branch from 6e4b0df to 59e884b Compare October 22, 2024 20:31
@briantu briantu force-pushed the briantu/pass-loading-context-in-batch branch from 51882eb to ef03572 Compare October 22, 2024 20:32
@briantu briantu force-pushed the briantu/make-compute-subset-async branch from 59e884b to 63c2dc8 Compare October 22, 2024 21:13
@briantu briantu force-pushed the briantu/pass-loading-context-in-batch branch from b6f1c2f to 3df060b Compare October 22, 2024 21:13
Copy link
Contributor Author

briantu commented Oct 22, 2024

Merge activity

  • Oct 22, 6:08 PM EDT: A user started a stack merge that includes this pull request via Graphite.
  • Oct 22, 6:30 PM EDT: Graphite rebased this pull request as part of a merge.
  • Oct 22, 6:31 PM EDT: A user merged this pull request with Graphite.

@briantu briantu changed the base branch from briantu/make-compute-subset-async to graphite-base/25377 October 22, 2024 22:25
@briantu briantu changed the base branch from graphite-base/25377 to master October 22, 2024 22:28
@briantu briantu force-pushed the briantu/pass-loading-context-in-batch branch from 3df060b to 45d68da Compare October 22, 2024 22:30
@briantu briantu merged commit 01efdf2 into master Oct 22, 2024
1 check failed
@briantu briantu deleted the briantu/pass-loading-context-in-batch branch October 22, 2024 22:31
Grzyblon pushed a commit to Grzyblon/dagster that referenced this pull request Oct 26, 2024
## Summary & Motivation
This lets us use the loading_context for get_asset_status_cache_values, which saves us from needing to re-fetch the asset records in here again.

Copied from demo PR dagster-io#25270

## How I Tested These Changes
Perf test before/after
```
pytest python_modules/dagster/dagster_tests/definitions_tests/declarative_automation_tests/perf_tests/test_perf.py
```
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