Skip to content

Commit

Permalink
Log finished outputs (#181)
Browse files Browse the repository at this point in the history
Fix #152.

I used `FINISHED_LOG` as the name for the option
to have it consistent with `MEMORY_PROFILE_LOG`.

I used `"log/finished.log"` as the default path
to have it consistent with `"log/manager.log.%s"`
from the manager UI.

I thought about whether to have this
enabled or disabled by default,
and decided that this should not add too much overhead,
so we can have this enabled by default.
  • Loading branch information
albertz authored Feb 11, 2024
1 parent 399b8d9 commit bc80ae7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions sisyphus/global_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,9 @@ def file_caching(path):
#: Print message for held jobs
PRINT_HOLD = True

#: Log for finished outputs.
FINISHED_LOG = "log/finished.log"

#: Which command should be called to start sisyphus, can be used to replace the python binary
SIS_COMMAND = [sys.executable, sys.argv[0]]
# if this first argument is -m it's missing the module name
Expand Down
10 changes: 10 additions & 0 deletions sisyphus/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import threading
from typing import DefaultDict, Optional, List
from multiprocessing.pool import ThreadPool
from datetime import datetime


class Node(object):
Expand Down Expand Up @@ -112,6 +113,15 @@ def run_when_done(self, write_output=None):
# Set new link if needed
os.symlink(os.path.realpath(self._sis_path.get_path()), outfile_name)
logging.info("Finished output: %s" % outfile_name)

if gs.FINISHED_LOG:
if "/" in gs.FINISHED_LOG and not os.path.exists(os.path.dirname(gs.FINISHED_LOG)):
os.makedirs(os.path.dirname(gs.FINISHED_LOG))
with open(gs.FINISHED_LOG, "a") as f:
f.write(
datetime.now().strftime("%Y-%m-%d %H:%M:%S: ") + f"Finished output: {outfile_name}\n"
)

except OSError as e:
logging.warning("Failed to updated output %s. Exception: %s" % (outfile_name, e))

Expand Down

0 comments on commit bc80ae7

Please sign in to comment.