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

fix: prevent name collisions on input parameters #365

Merged
merged 2 commits into from
Jan 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions latch_cli/snakemake/workflow.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import hashlib
import importlib
import json
import sys
import textwrap
import typing
from dataclasses import dataclass
from pathlib import Path
from textwrap import dedent
from typing import (
Any,
Dict,
Expand All @@ -19,6 +21,7 @@
)
from urllib.parse import urlparse

import click
import snakemake
import snakemake.io
import snakemake.jobs
Expand Down Expand Up @@ -183,6 +186,21 @@ def snakemake_dag_to_interface(
RemoteFile(local_path=x, remote_path=remote_url)
)

# it is possible for two different input files to have the same parameter name
# as long as they are defined in different rules. This can lead to name collisions
# because we use a global mapping (across all rules) of param_name -> input_file.
if param in literals and literals[param].scalar.blob.uri != remote_url:
click.secho(
dedent(f"""
Name collision detected for {job.name}. The following two input
parameters have the same name but different remote paths:
{param} -> {remote_url}
{param} -> {literals[param].scalar.blob.uri}
"""),
fg="red",
)
sys.exit(1)

literals[param] = Literal(
scalar=Scalar(
blob=Blob(
Expand Down
Loading