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

Feature/hooks track operation #739

Merged
merged 82 commits into from
Dec 4, 2023
Merged

Feature/hooks track operation #739

merged 82 commits into from
Dec 4, 2023

Conversation

klywang
Copy link
Contributor

@klywang klywang commented Apr 19, 2023

Implemented builtin TrackOperations hooks. TrackOperations keeps detailed metadata records about the project directory and operations as a log file, optionally in conjunction with git (#637).

Description

Added TrackOperations utilities to signac-flow hooks and added tests. Some of these tests require gitpython. We made this an optional dependency for testing since there are no other tests in signac-flow which require gitpython.

In the original implementation of TrackOperations (#189), operation directives were recorded in the metadata. However, our current implementation of hooks takes in operation as a string and job as signac.job.Job. Does anyone know how we could access directives in the current implementation of hooks?

Motivation and Context

TrackOperations are a useful way to track the state of your code when a specific job operation is executed.

Checklist:

@klywang klywang requested review from a team as code owners April 19, 2023 16:23
@klywang klywang requested review from csadorf and SchoeniPhlippsn and removed request for a team April 19, 2023 16:23
@codecov
Copy link

codecov bot commented Apr 19, 2023

Codecov Report

Attention: 5 lines in your changes are missing coverage. Please review.

Comparison is base (5106e65) 69.08% compared to head (d35908d) 69.41%.

Files Patch % Lines
flow/hooks/track_operations.py 89.79% 3 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #739      +/-   ##
==========================================
+ Coverage   69.08%   69.41%   +0.32%     
==========================================
  Files          45       48       +3     
  Lines        4348     4407      +59     
  Branches      890     1065     +175     
==========================================
+ Hits         3004     3059      +55     
- Misses       1138     1140       +2     
- Partials      206      208       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@bdice bdice left a comment

Choose a reason for hiding this comment

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

Feedback attached.

Examples
--------
The following example will install :class:`~.TrackOperations` at the operation level.
Where the log will be stored in the job document.
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure what is meant here. Is this a complete sentence?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah need to fix.

flow/hooks/track_operations.py Outdated Show resolved Hide resolved
flow/hooks/track_operations.py Outdated Show resolved Hide resolved
flow/hooks/track_operations.py Outdated Show resolved Hide resolved
flow/hooks/track_operations.py Outdated Show resolved Hide resolved
flow/hooks/util.py Outdated Show resolved Hide resolved
flow/hooks/util.py Outdated Show resolved Hide resolved
):
assert metadata["stage"] == expected_stage
# When running on MacOS CI a private/ is prepended to job.project.path
# seemingly indeterminetly. If metadata["project"]["path"] is checked
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
# seemingly indeterminetly. If metadata["project"]["path"] is checked
# seemingly indeterminately. If metadata["project"]["path"] is checked

repo,
):
assert metadata["stage"] == expected_stage
# When running on MacOS CI a private/ is prepended to job.project.path
Copy link
Member

Choose a reason for hiding this comment

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

This is rather surprising behavior. I would encourage finding a way to have deterministic tests.

Copy link
Member

Choose a reason for hiding this comment

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

I thought about this a bit more. I would xfail or skip this test on macOS rather than introduce a lot of workarounds in the testing code.

Comment on lines 2686 to 2689
else:
if self.error_on_no_git:
# Should not happen in actual testing, here for developers.
assert False, "Expected gitpython for test."
Copy link
Member

Choose a reason for hiding this comment

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

This doesn't seem right. What is "actual testing"? Do you mean CI is "actual testing" but local runs of the test suite are not? It is okay to require that developers have gitpython installed to run the test suite, or you can edit tests requiring gitpython to call pytest.importorskip.

Copy link
Contributor

Choose a reason for hiding this comment

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

We can assume that the git package is present during testing since we skip the tests on the import error.

Copy link
Member

Choose a reason for hiding this comment

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

It isn't testing in any case. It is there to ensure we never reach this point. It should be impossible to get here. If that isn't the case there is an error in the test.

@b-butler b-butler requested a review from bdice November 13, 2023 21:55
Copy link
Contributor

@csadorf csadorf left a comment

Choose a reason for hiding this comment

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

Please address the tiny errors I found in the documentation, but otherwise it looks good to me.

flow/hooks/track_operations.py Outdated Show resolved Hide resolved
flow/hooks/track_operations.py Outdated Show resolved Hide resolved
flow/hooks/track_operations.py Outdated Show resolved Hide resolved
Copy link
Member

@bdice bdice left a comment

Choose a reason for hiding this comment

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

One last round of suggestions, but approving. Please merge when you're ready, but I don't think I can offer more feedback based on the time I've invested here already.

flow/hooks/track_operations.py Outdated Show resolved Hide resolved
flow/hooks/track_operations.py Outdated Show resolved Hide resolved
flow/hooks/track_operations.py Outdated Show resolved Hide resolved
flow/hooks/track_operations.py Outdated Show resolved Hide resolved
flow/hooks/track_operations.py Outdated Show resolved Hide resolved
flow/hooks/track_operations.py Outdated Show resolved Hide resolved
flow/hooks/track_operations.py Outdated Show resolved Hide resolved
flow/hooks/track_operations.py Outdated Show resolved Hide resolved
tests/define_hooks_track_operations_project.py Outdated Show resolved Hide resolved
tests/test_project.py Outdated Show resolved Hide resolved
@csadorf
Copy link
Contributor

csadorf commented Nov 27, 2023

@b-butler Do you think you will be able to merge this soon?

@b-butler b-butler enabled auto-merge (squash) December 4, 2023 18:30
@b-butler b-butler merged commit f69aeb5 into main Dec 4, 2023
11 checks passed
@b-butler b-butler deleted the feature/hooks-TrackOperation branch December 4, 2023 19:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants