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: AmbiguousRuleException bug caused by weak ordering of rules #1124

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
36 changes: 18 additions & 18 deletions snakemake/dag.py
Expand Up @@ -731,9 +731,8 @@ def update(
visited = set()
if known_producers is None:
known_producers = dict()
producer = None
producers = []
exceptions = list()
jobs = sorted(jobs, reverse=not self.ignore_ambiguity)
cycles = list()

for job in jobs:
Expand All @@ -756,12 +755,7 @@ def update(
)
# TODO this might fail if a rule discarded here is needed
# elsewhere
if producer:
if job < producer or self.ignore_ambiguity:
break
elif producer is not None:
raise AmbiguousRuleException(file, job, producer)
producer = job
producers.append(job)
except (
MissingInputException,
CyclicGraphException,
Expand All @@ -783,29 +777,35 @@ def update(
if file
else "",
)
if producer is None:
if not producers:
if cycles:
job = cycles[0]
raise CyclicGraphException(job.rule, file, rule=job.rule)
if len(exceptions) > 1:
raise WorkflowError(*exceptions)
elif len(exceptions) == 1:
raise exceptions[0]
else:
logger.dag_debug(dict(status="selected", job=producer))
logger.dag_debug(
dict(
file=file,
msg="Producer found, hence exceptions are ignored.",
exception=WorkflowError(*exceptions),
)
)

n = len(self.dependencies)
if progress and n % 1000 == 0 and n and self._progress != n:
logger.info("Processed {} potential jobs.".format(n))
self._progress = n

producers.sort(reverse=True)
johanneskoester marked this conversation as resolved.
Show resolved Hide resolved
producer = producers[0]
ambiguities = list(
filter(lambda x: not x < producer and not producer < x, producers[1:])
)
if ambiguities and not self.ignore_ambiguity:
raise AmbiguousRuleException(file, producer, ambiguities[0])
logger.dag_debug(dict(status="selected", job=producer))
logger.dag_debug(
dict(
file=file,
msg="Producer found, hence exceptions are ignored.",
exception=WorkflowError(*exceptions),
)
)
return producer

def update_(
Expand Down