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

[BEAM-10052] check hash and avoid duplicated artifacts #11771

Merged
merged 1 commit into from May 21, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 11 additions & 1 deletion sdks/python/apache_beam/runners/dataflow/internal/apiclient.py
Expand Up @@ -583,6 +583,7 @@ def _stage_resources(self, pipeline, options):
raise RuntimeError('The --temp_location option must be specified.')

resources = []
hashs = {}
for _, env in sorted(pipeline.components.environments.items(),
key=lambda kv: kv[0]):
for dep in env.dependencies:
Expand All @@ -595,7 +596,16 @@ def _stage_resources(self, pipeline, options):
role_payload = (
beam_runner_api_pb2.ArtifactStagingToRolePayload.FromString(
dep.role_payload))
resources.append((type_payload.path, role_payload.staged_name))
if type_payload.sha256 and type_payload.sha256 in hashs:
_LOGGER.info(
'Found duplicated artifact: %s (%s)',
type_payload.path,
type_payload.sha256)
dep.role_payload = beam_runner_api_pb2.ArtifactStagingToRolePayload(
staged_name=hashs[type_payload.sha256]).SerializeToString()
else:
resources.append((type_payload.path, role_payload.staged_name))
hashs[type_payload.sha256] = role_payload.staged_name

resource_stager = _LegacyDataflowStager(self)
staged_resources = resource_stager.stage_job_resources(
Expand Down