Skip to content

Commit

Permalink
Merge pull request #158 from cgat-developers/AC-paramoutput
Browse files Browse the repository at this point in the history
The pipeline outputs the global params before they are updated. The p…
  • Loading branch information
Adam Cribbs authored Apr 11, 2022
2 parents cf5f969 + 7f5c5c8 commit a0cd954
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 4 deletions.
3 changes: 0 additions & 3 deletions cgatcore/experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -1049,9 +1049,6 @@ def start(parser=None,
else:
logger = logging.getLogger("cgatcore")

logger.info(get_header())
logger.info(get_params(global_options))

if global_options.tracing == "function":
sys.settrace(trace_calls)

Expand Down
28 changes: 28 additions & 0 deletions cgatcore/pipeline/control.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import math
import os
import re
import inspect
import shutil
import subprocess
import sys
Expand All @@ -46,6 +47,7 @@
import cgatcore.experiment as E
import cgatcore.iotools as iotools
from cgatcore.pipeline.parameters import input_validation, get_params, get_parameters
from cgatcore.experiment import get_header, MultiLineFormatter
from cgatcore.pipeline.utils import get_caller, get_caller_locals, is_test
from cgatcore.pipeline.execution import execute, start_session,\
close_session
Expand Down Expand Up @@ -106,6 +108,28 @@ def get_logger():
return logging.getLogger("cgatcore.pipeline")


def get_param_output(options=None):
"""return a string containing script parameters.
Parameters are all variables that start with ``param_``.
"""
result = []
if options:
members = options
for k, v in sorted(members.items()):
result.append("%-40s: %s" % (k, str(v)))
else:
vars = inspect.currentframe().f_back.f_locals
for var in [x for x in list(vars.keys()) if re.match("param_", x)]:
result.append("%-40s: %s" %
(var, str(vars[var])))

if result:
return "\n".join(result)
else:
return "# no parameters."


def write_config_files(pipeline_path, general_path):
'''create default configuration files in `path`.
'''
Expand Down Expand Up @@ -1209,6 +1233,10 @@ def initialize(argv=None, caller=None, defaults=None, optparse=True, **kwargs):
# configuration files.
update_params_with_commandline_options(get_params(), args)

logger.info(get_header())

logger.info(get_param_output(get_params()))

code_location, version = get_version()
logger.info("code location: {}".format(code_location))
logger.info("code version: {}".format(version))
Expand Down
2 changes: 1 addition & 1 deletion cgatcore/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.6.10"
__version__ = "0.6.11"

0 comments on commit a0cd954

Please sign in to comment.