Skip to content
Permalink
Browse files
fix: AmbiguousRuleException bug caused by weak ordering of rules (#1124)
Link to the issue: #1106

Co-authored-by: Johannes Köster <johannes.koester@uni-due.de>
  • Loading branch information
dkuzminov and johanneskoester committed Aug 23, 2021
1 parent edadd41 commit 7f54c391f2821655ed168bcdafad6d07b96fcec7
Showing 1 changed file with 18 additions and 18 deletions.
@@ -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:
@@ -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,
@@ -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)
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_(

0 comments on commit 7f54c39

Please sign in to comment.