1. Sean Davis
  2. Snakemake

Commits

Sean Davis  committed 2ff390c

Run snakemake in dryrun mode even when another snakemake has locked directory.

When running long workflows, it is useful to be able to check on the number of
rules still needed to run, compute a partial DAG, etc. Many such "read-only"
operations were prohibited due to the exclusive lock. A small change to
workflow allows "read-only" operations even while a workflow is currently running.

  • Participants
  • Parent commits 8a1bc41

Comments (0)

Files changed (1)

File snakemake/workflow.py

View file
             return False
 
         if unlock:
+            if not dryrun:
+                try:
+                    self.persistence.cleanup_locks()
+                    logger.warning("Unlocking working directory.")
+                    return True
+                except IOError:
+                    logger.error("Error: Unlocking the directory {} failed. Maybe "
+                    "you don't have the permissions?")
+                    return False
             try:
-                self.persistence.cleanup_locks()
-                logger.warning("Unlocking working directory.")
-                return True
+                self.persistence.lock()
             except IOError:
-                logger.error("Error: Unlocking the directory {} failed. Maybe "
-                "you don't have the permissions?")
+                logger.critical("Error: Directory cannot be locked. Please make "
+                    "sure that no other Snakemake process is trying to create "
+                    "the same files in the following directory:\n{}\n"
+                    "If you are sure that no other "
+                    "instances of snakemake are running on this directory, "
+                    "the remaining lock was likely caused by a kill signal or "
+                    "a power loss. It can be removed with "
+                    "the --unlock argument.".format(os.getcwd()))
                 return False
-        try:
-            self.persistence.lock()
-        except IOError:
-            logger.critical("Error: Directory cannot be locked. Please make "
-                "sure that no other Snakemake process is trying to create "
-                "the same files in the following directory:\n{}\n"
-                "If you are sure that no other "
-                "instances of snakemake are running on this directory, "
-                "the remaining lock was likely caused by a kill signal or "
-                "a power loss. It can be removed with "
-                "the --unlock argument.".format(os.getcwd()))
-            return False
 
         if printdag:
             print(dag)