Skip to content

Commit

Permalink
potential fix for #201
Browse files Browse the repository at this point in the history
  • Loading branch information
donaldcampbelljr committed Nov 15, 2023
1 parent ed6b7fb commit b0c5f8d
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions pypiper/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -1587,7 +1587,9 @@ def _report_profile(
with open(self.pipeline_profile_file, "a") as myfile:
myfile.write(message_raw + "\n")

def report_result(self, key, value, nolog=False, result_formatter=None):
def report_result(
self, key, value, nolog=False, result_formatter=None, force_overwrite=False
):
"""
Writes a key:value pair to self.pipeline_stats_file.
Expand All @@ -1597,6 +1599,7 @@ def report_result(self, key, value, nolog=False, result_formatter=None):
logfile. Use sparingly in case you will be printing the result in a
different format.
:param str result_formatter: function for formatting via pipestat backend
:param bool force_overwrite: overwrite results if they already exist?
:return str reported_result: the reported result is returned as a list of formatted strings.
"""
Expand All @@ -1609,11 +1612,17 @@ def report_result(self, key, value, nolog=False, result_formatter=None):
values={key: value},
record_identifier=self.pipestat_record_identifier,
result_formatter=rf,
force_overwrite=force_overwrite,
)

if not nolog:
for r in reported_result:
self.info(r)
if isinstance(
reported_result, bool
): # Pipestat can return False if results are NOT reported.
self.info("Result successfully reported? " + str(reported_result))
else:
for r in reported_result:
self.info(r)

return reported_result

Expand All @@ -1626,6 +1635,7 @@ def report_object(
annotation=None,
nolog=False,
result_formatter=None,
force_overwrite=False,
):
"""
Writes a key:value pair to self.pipeline_stats_file. Note: this function
Expand All @@ -1646,6 +1656,7 @@ def report_object(
logfile. Use sparingly in case you will be printing the result in a
different format.
:param str result_formatter: function for formatting via pipestat backend
:param bool force_overwrite: overwrite results if they already exist?
:return str reported_result: the reported result is returned as a list of formatted strings.
"""
warnings.warn(
Expand Down Expand Up @@ -1692,11 +1703,17 @@ def report_object(
values=val,
record_identifier=self.pipestat_record_identifier,
result_formatter=rf,
force_overwrite=force_overwrite,
)

if not nolog:
for r in reported_result:
self.info(r)
return reported_result
if isinstance(
reported_result, bool
): # Pipestat can return False if results are NOT reported.
self.info("Result successfully reported? " + str(reported_result))
else:
for r in reported_result:
self.info(r)

def _safe_write_to_file(self, file, message):
"""
Expand Down

0 comments on commit b0c5f8d

Please sign in to comment.