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 checksum timestamp changes #371

Merged
merged 4 commits into from
Nov 13, 2023
Merged

add checksum timestamp changes #371

merged 4 commits into from
Nov 13, 2023

Conversation

brynnz22
Copy link
Contributor

@brynnz22 brynnz22 commented Nov 8, 2023

#340

Hi @dwinston , I am unfamiliar with the hashlib library, so I'm not sure about the code I added to the sha256hash_from_file function. I think this is what you meant.

Thanks!

@brynnz22 brynnz22 requested review from eecavanna and dwinston and removed request for eecavanna November 10, 2023 19:18
@@ -442,6 +442,7 @@ def persist_content_and_get_drs_object(
),
"access_methods": [{"access_id": drs_id}],
},
timestamp= datetime.now(tz=ZoneInfo('America/Los_Angeles')).isoformat(timespec='minutes')
Copy link
Collaborator

Choose a reason for hiding this comment

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

This change makes sense to me.

A string is being generated that indicates the current time (in Los Angeles, CA) down to the minute.

Docs for datetime.isoformat() say it returns a string representation of the time in ISO 8601 format.

image

Copy link
Collaborator

@eecavanna eecavanna Nov 10, 2023

Choose a reason for hiding this comment

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

I recommend removing the space after the equals sign, since this is "keyword argument setting" as opposed to "variable assignment" (I think that's a Python convention).

- timestamp= datetime.now(...
+ timestamp=datetime.now(...

@eecavanna eecavanna self-requested a review November 10, 2023 21:04
eecavanna
eecavanna previously approved these changes Nov 10, 2023
Copy link
Collaborator

@eecavanna eecavanna left a comment

Choose a reason for hiding this comment

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

The code changes, in isolation, make sense to me. I will defer to @dwinston for final approval and merging, as I'm not too familiar with the context (i.e. this part of the code base) and I think these changes stemmed from a comment he made in #340 (comment).

@PeopleMakeCulture PeopleMakeCulture linked an issue Nov 13, 2023 that may be closed by this pull request
@@ -431,17 +431,21 @@ def persist_content_and_get_drs_object(
filepath = str(Path(save_dir).joinpath(filename))
with open(filepath, "w") as f:
f.write(content)
now_to_the_minute = datetime.now(tz=ZoneInfo("America/Los_Angeles")).isoformat(
Copy link
Collaborator

Choose a reason for hiding this comment

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

style: creating this in one place

TEST_FILES_DIR = Path(__file__).parent.parent.joinpath("files")


def test_sha256hash_from_file_is_timestamp_dependent():
Copy link
Collaborator

Choose a reason for hiding this comment

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

adding unit test

@dwinston dwinston merged commit fd3aee9 into main Nov 13, 2023
@dwinston dwinston deleted the issue340-checksum-timestamp branch November 13, 2023 16:11
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.

Checksum Matches Existing Object - Json submit endpoint
3 participants