Skip to content

Commit

Permalink
make job_name param on PartitionArgs and PartitionNames args optional
Browse files Browse the repository at this point in the history
  • Loading branch information
sryza committed Aug 27, 2024
1 parent 1e9102f commit 5f1de9b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
12 changes: 6 additions & 6 deletions python_modules/dagster/dagster/_grpc/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,10 +408,10 @@ class PartitionArgs(
"_PartitionArgs",
[
("repository_origin", RemoteRepositoryOrigin),
("job_name", str),
# This is here for backcompat. it's expected to always be f"{job_name}_partition_set".
("partition_set_name", str),
("partition_name", str),
("job_name", Optional[str]),
("instance_ref", Optional[InstanceRef]),
# This is introduced in the same release that we're making it possible for an asset job
# to target assets with different PartitionsDefinitions. Prior user code versions can
Expand All @@ -424,9 +424,9 @@ class PartitionArgs(
def __new__(
cls,
repository_origin: RemoteRepositoryOrigin,
job_name: str,
partition_set_name: str,
partition_name: str,
job_name: Optional[str] = None,
instance_ref: Optional[InstanceRef] = None,
selected_asset_keys: Optional[AbstractSet[AssetKey]] = None,
):
Expand All @@ -438,7 +438,7 @@ def __new__(
RemoteRepositoryOrigin,
),
partition_set_name=check.str_param(partition_set_name, "partition_set_name"),
job_name=check.str_param(job_name, "job_name"),
job_name=check.opt_str_param(job_name, "job_name"),
partition_name=check.str_param(partition_name, "partition_name"),
instance_ref=check.opt_inst_param(instance_ref, "instance_ref", InstanceRef),
selected_asset_keys=check.opt_nullable_set_param(
Expand All @@ -459,30 +459,30 @@ class PartitionNamesArgs(
"_PartitionNamesArgs",
[
("repository_origin", RemoteRepositoryOrigin),
("job_name", str),
# This is here for backcompat. it's expected to always be f"{job_name}_partition_set".
("partition_set_name", str),
# This is introduced in the same release that we're making it possible for an asset job
# to target assets with different PartitionsDefinitions. Prior user code versions can
# (and do) safely ignore this parameter, because, in those versions, the job name on its
# own is enough to specify which PartitionsDefinition to use.
("job_name", Optional[str]),
("selected_asset_keys", Optional[AbstractSet[AssetKey]]),
],
)
):
def __new__(
cls,
repository_origin: RemoteRepositoryOrigin,
job_name: str,
partition_set_name: str,
job_name: Optional[str] = None,
selected_asset_keys: Optional[AbstractSet[AssetKey]] = None,
):
return super(PartitionNamesArgs, cls).__new__(
cls,
repository_origin=check.inst_param(
repository_origin, "repository_origin", RemoteRepositoryOrigin
),
job_name=check.str_param(job_name, "job_name"),
job_name=check.opt_str_param(job_name, "job_name"),
partition_set_name=check.str_param(partition_set_name, "partition_set_name"),
selected_asset_keys=check.opt_nullable_set_param(
selected_asset_keys, "selected_asset_keys", of_type=AssetKey
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,3 +340,25 @@ def test_dynamic_partition_set_grpc(instance: DagsterInstance):
)
assert isinstance(data, ExternalPartitionSetExecutionParamData)
assert data.partition_data == []


def test_external_partition_tags_grpc_backcompat_no_job_name(instance: DagsterInstance):
with get_bar_repo_code_location(instance) as code_location:
repository_handle = code_location.get_repository("bar_repo").handle

api_client = code_location.client

result = deserialize_value(
api_client.external_partition_tags(
partition_args=PartitionArgs(
repository_origin=repository_handle.get_external_origin(),
partition_set_name="baz_partition_set",
partition_name="c",
instance_ref=instance.get_ref(),
)
)
)

assert isinstance(result, ExternalPartitionTagsData)
assert result.tags
assert result.tags["foo"] == "bar"

0 comments on commit 5f1de9b

Please sign in to comment.