Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add method runtime parameters to logging #1685

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions starfish/core/pipeline/algorithmbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,19 @@ def helper(*args, **kwargs):
method_class_str = str(args[0].__class__)
if 'ApplyTransform' in method_class_str or 'Filter' in method_class_str:
# Update the log on the resulting ImageStack
result.log.update_log(args[0])
result.log.update_log(args[0], kwargs)
if 'FindSpots' in method_class_str:
# Update the log on the resulting SpotFindingResults
result.log.update_log(args[0])
result.log.update_log(args[0], kwargs)
if 'DecodeSpots' in method_class_str:
# update log then transfer to DecodedIntensityTable
spot_results = kwargs['spots']
spot_results.log.update_log(args[0])
spot_results.log.update_log(args[0], kwargs)
result.attrs[STARFISH_EXTRAS_KEY] = spot_results.log.encode()
if 'DetectPixels' in method_class_str:
stack = args[1]
# update log with spot detection instance args[0]
stack.log.update_log(args[0])
stack.log.update_log(args[0], kwargs)
# get resulting intensity table and set log
it = result[0]
it.attrs[STARFISH_EXTRAS_KEY] = stack.log.encode()
Expand Down
7 changes: 5 additions & 2 deletions starfish/core/util/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,23 @@ def __init__(self):
"""
self._log: List[dict] = list()

def update_log(self, class_instance) -> None:
def update_log(self, class_instance, method_runtime_parameters=None) -> None:
"""
Adds a new entry to the log list.

Parameters
----------
class_instance: The instance of a class being applied to the imagestack

method_runtime_parameters: Any runtime parameters passed to the method
"""
entry = {"method": class_instance.__class__.__name__,
"method_runtime_parameters": method_runtime_parameters,
"arguments": class_instance.__dict__,
"os": get_os_info(),
"dependencies": get_core_dependency_info(),
"release tag": get_release_tag(),
"starfish version": get_dependency_version('starfish')
"starfish version": get_dependency_version('starfish'),
}
self._log.append(entry)

Expand Down
1 change: 1 addition & 0 deletions starfish/test/full_pipelines/api/test_iss_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ def test_iss_pipeline_cropped_data(tmpdir):

assert pipeline_log[0]['method'] == 'WhiteTophat'
assert pipeline_log[1]['method'] == 'Warp'
assert 'transforms_list' in pipeline_log[1]['method_runtime_parameters']
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So when it logs the transforms list, what gets logged here? The actual object?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the string representation of the object

assert pipeline_log[2]['method'] == 'BlobDetector'
assert pipeline_log[3]['method'] == 'PerRoundMaxChannel'

Expand Down