0

I am trying to create a custom log_handler script that can save the workflow´s log as a JSON file inside {workdir}/logs. For that I need to know what is the current workdir but I cannot seem to access is from inside the script. Does anyone know how to access workdir from inside a log_handler script?

I have also tried using Path.cwd() from inside the script, but it did not work.

EDIT: to clarify this a bit more, snakemake allows to specify a --log-handler-script. According to the documentation:

Provide a custom script containing a function ‘def log_handler(msg):’. Snakemake will call this function for every logging output (given as a dictionary msg) allowing to e.g. send notifications in the form of e.g. slack messages or emails.

I am trying to write such a script (based on this) that parses the log messages and saves them in a file, ideally, inside the workdir. But for that, the script needs to be able to know the current workdir.

thanks,

FGV
  • 99
  • 1
  • 8
  • Maybe it's me being thick but without an example I cannot understand what you are trying to do... Can you post an example of what the log_handler script should do (is this python, bash, or else?) and how you want to integrate it in the Snakefile? – dariober Feb 01 '22 at 09:27
  • Would `workflow.basedir` do the trick? – fgypas Feb 02 '22 at 11:06
  • Already tried, and I get: `AttributeError: module 'snakemake.workflow' has no attribute 'basedir'` or `NameError: name 'workflow' is not defined` – FGV Feb 03 '22 at 12:16

0 Answers0