https://dagster.io/ logo
#ask-community
Title
# ask-community
a

Andrew

02/22/2023, 11:10 AM
I'm getting this graphql error in my staging environment on EC2, but I can't recreate it locally. It also never loads my 20k partitions for this particular asset. Locally - this works.
Copy code
BAR_PARTITIONS = ['foo-99501',
 'foo-99502',
 'foo-99503',
 'foo-99504', ... ]

monthly_partition_def = MonthlyPartitionsDefinition(
    start_date=datetime(2023, 2, 1), timezone="America/New_York", end_offset=1
)
bar_partition_def = StaticPartitionsDefinition(BAR_PARTITIONS)
foo_monthly_bar_partition_def = MultiPartitionsDefinition(
    {
        "bar_link": bar_partition_def,
        "date": monthly_partition_def,
    }
)
The Error
Copy code
Operation name: PartitionHealthQuery

Message: Failure condition: No partitions in the PartitionsDefinition

Path: ["assetNodeOrError","materializedPartitions"]

Locations: [{"line":10,"column":7}]
c

claire

02/22/2023, 5:33 PM
Hi Andrew, what version of dagster are you running?
a

Andrew

02/22/2023, 6:09 PM
1.1.19 @claire
The asset in question does something similar to this
Copy code
@asset(
    name="bar_link",
    partitions_def=foo_monthly_bar_partition_def,
    code_version="0.1",
)
def scheduled_state_partition(context) -> Output[str]:
    partition_keys = context.partition_key.keys_by_dimension
    date_partition = partition_keys.get("date")
    bar_partition = partition_keys.get("state")
    area_link = f"<https://www.foo.com/{bar_partition}/>"

    return Output(
        area_link,
        metadata={"date_partition": date_partition, "bar_partition": bar_partition},
    )
(This has other issues - mainly that the context errors out on accessing the partition_key - but I'm reporting this node issue.)
c

claire

02/23/2023, 12:58 AM
Got it--I was able to figure out the source of the issue. We're making a call to get the first partition window, and that function isn't respecting the end offset so is returning None. I'll put a fix out for this (should make it into next week's release).
I'm also happy to take a stab at fixing the context erroring out on accessing the partition key, if you have a stack trace you can share
a

Andrew

02/23/2023, 2:00 AM
Copy code
dagster._check.CheckError: Invariant failed. Description: Tried to access partition_key for a non-partitioned run
  File "/opt/conda/envs/dagster/lib/python3.10/site-packages/dagster/_core/execution/plan/utils.py", line 55, in op_execution_error_boundary
    yield
  File "/opt/conda/envs/dagster/lib/python3.10/site-packages/dagster/_utils/__init__.py", line 471, in iterate_with_context
    next_output = next(iterator)
  File "/opt/conda/envs/dagster/lib/python3.10/site-packages/dagster/_core/execution/plan/compute_generator.py", line 121, in _coerce_solid_compute_fn_to_iterator
    result = invoke_compute_fn(
  File "/opt/conda/envs/dagster/lib/python3.10/site-packages/dagster/_core/execution/plan/compute_generator.py", line 115, in invoke_compute_fn
    return fn(context, **args_to_pass) if context_arg_provided else fn(**args_to_pass)
  File "foo.py", line 45, in monthly_by_bar_partition
    partition_keys = context.partition_key.keys_by_dimension
  File "/opt/conda/envs/dagster/lib/python3.10/site-packages/dagster/_core/execution/context/compute.py", line 284, in partition_key
    return self._step_execution_context.partition_key
  File "/opt/conda/envs/dagster/lib/python3.10/site-packages/dagster/_core/execution/context/system.py", line 350, in partition_key
    check.invariant(
  File "/opt/conda/envs/dagster/lib/python3.10/site-packages/dagster/_check/__init__.py", line 1684, in invariant
    raise CheckError(f"Invariant failed. Description: {desc}")
@claire Would appreciate it! i've been poking around and trying to get an idea of what's going on when I trigger a backfill.
Is there a best practice for accessing the key/partitions of a multipartiton during a backfill OR a single asset materialization?
c

claire

02/23/2023, 7:23 PM
Hi Andrew. Usually that error pops up when
context.partition_key
is invoked on an un-partitioned asset or un-partitioned job. Is that error happening on your asset with
partitions_def=foo_monthly_bar_partition_def
? Are you defining any jobs with that asset that are unpartitioned?
context.partition_key
is the recommended way to access the partition key during both a backfill and a single materialization
a

Andrew

02/23/2023, 7:41 PM
I have no unpartitioned jobs. only multipartioned jobs with between 19k and 40k partitions. The intent was to start their runs this month so there’s only one time partition
For the most part, they all share the same root. I will try to test on a non-multipartitioned asset, and an asset without any partition.
And yes - that error is happening on the aforementioned asset.
c

claire

02/23/2023, 10:12 PM
Still trying to repro this, but here'a fix for the graphql error: https://github.com/dagster-io/dagster/pull/12504
Hi Andrew, wanted to follow up on this after chatting with @Zach Hill. I was able to repro the issue--seems like it's happening when the "pass partition ranges to single run" checkbox is selected.
If you select this checkbox, you can do
context.asset_partition_key_range
to access the partition key range. Then you can do something like
partitions_def.get_partition_keys_in_range(partition_key_range)
to fetch the partition keys in the range. For each partition key, you can do something like
partition_key.keys_by_dimension
. This functionality still requires a bit of work since we recently released the functionality to execute ranges in a single run, so when runs are executed this way the context methods sometimes return strings rather than `MultiPartitionKey`s. The fallback is not selecting the "pass partition ranges to single run" option--the context methods should work as expected in that case. Thanks for describing the error. We should be able to make at least the
context.partition_key
error more informative and fix the
MultiPartitionKey
issues
https://github.com/dagster-io/dagster/pull/12512 this PR enables the context methods to return
MultiPartitionKey
instances when the "launch as single run" box is selected
👍 1
a

Andrew

02/24/2023, 1:27 AM
Awesome thank you 🙏🏻 . Will incorporate these as we wait for the next update. Really appreciate the help
🌈 1
2 Views