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

feat(JA): Add force-rehash option to snapshot command. Integ test refactoring. #477

Merged
merged 1 commit into from
Oct 18, 2024

Conversation

leongdl
Copy link
Contributor

@leongdl leongdl commented Oct 17, 2024

What was the problem/requirement? (What/Why)

  • Customers have requested APIs and CLI interfaces to use Job Attachments.
  • We designed new CLI + APIs:
    • manifest snapshot
    • manifest diff
    • manifest download
    • manifest upload
    • attachment upload
    • attachment download.

What was the solution? (How)

  • In this PR, I am working on the code coverage, bug fix and adding feature parity to manifest snapshot. In manifest diff, I added a force-rehash option code path that allows users to rehash all files. I'm adding this also to snapshot so users can explicitly re-hash all files instead of comparing only by time stamp.

What is the impact of this change?

  • This new CLI + API will allow users to compare a Job Attachment manifest against the latest files in the local file system. Then customers can make a decision to make a new manifest file or not.

How was this change tested?

  • Manual testing
deadline manifest snapshot --root ./src --destination ~/work/manifest/ --name helloworld
deadline manifest snapshot --root ./src --destination ~/work/manifest/ --name helloworld --json
deadline manifest diff --root ./src --manifest ~/work/manifest/helloworld-702b85015b512373ecedb3231b322471-2024-10-17T17-15-08.manifest
deadline manifest diff --root ./src --manifest ~/work/manifest/helloworld-702b85015b512373ecedb3231b322471-2024-10-17T17-15-08.manifest --json
  • Have you run the unit tests?
    • Yes, hatch run test passes.
  • Have you run the integration tests?
    • Yes hatch run integ:test passes.
======================================================================================= 
24 passed, 2 skipped, 5 warnings in 52.69s =======================================================================================

  • Have you made changes to the download or asset_sync modules? If so, then it is highly recommended
    that you ensure that the docker-based unit tests pass.
    • Not applicable, Diff and Snapshot only does manifest operations.

Was this change documented?

  • Are relevant docstrings in the code base updated?

    • Yes
  • Has the README.md been updated? If you modified CLI arguments, for instance.

    • Readme and examples will be added once the feature stablizes.

Does this PR introduce new dependencies?

This library is designed to be integrated into third-party applications that have bespoke and customized deployment environments. Adding dependencies will increase the chance of library version conflicts and incompatabilities. Please evaluate the addition of new dependencies. See the Dependencies section of DEVELOPMENT.md for more details.

  • This PR adds one or more new dependency Python packages. I acknowledge I have reviewed the considerations for adding dependencies in DEVELOPMENT.md.
  • This PR does not add any new dependencies.

Is this a breaking change?

  • No.

Does this change impact security?

  • Yes, this will be security reviewed.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@leongdl leongdl changed the title feat(JA): WIP - Implementation for Job Attachments diff command feat(JA): WIP - Add force-rehash option to snapshot command. Integ test refactoring. Oct 17, 2024
@@ -38,7 +40,9 @@ def _create_manifest_for_single_root(
total_input_files=upload_group.total_input_files,
total_input_bytes=upload_group.total_input_bytes,
print_function_callback=logger.echo,
hashing_progress_callback=hash_callback_manager.callback,
hashing_progress_callback=(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was a BUG and printed out text for --json

Copy link
Contributor Author

Choose a reason for hiding this comment

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

All unit tests w/ --json now does a json.loads of the output to make sure json parsing never breaks.

@godobyte
Copy link
Contributor

Could you remove the src/hello file committed from #465?

# When
runner = CliRunner()
# Temporary, always add cli_manifest until launched.
main.add_command(cli_manifest)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit - this is not needed anymore, we can probably do a pass to clean them all.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good call, let me scrub them.

@@ -213,6 +213,15 @@ def _manifest_diff(

output: ManifestDiff = ManifestDiff()

# Helper function to update output datastructure.
def process_output(status: FileStatus, path: str, output_diff: ManifestDiff):
Copy link
Contributor

Choose a reason for hiding this comment

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

This file is a public interface, we should keep this helper private by prefixing _process_output.

Copy link
Contributor Author

@leongdl leongdl Oct 18, 2024

Choose a reason for hiding this comment

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

No need, this is a nested function in a function! So its not exposed.

Line 178 above already has _manifest_diff

Copy link
Contributor

Choose a reason for hiding this comment

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

Ahh didn't notice it's nested. Nice!

Comment on lines -17 to -18
@pytest.mark.skip("Random Failure with no credentials on Github")
class TestSnapshot:
Copy link
Contributor

Choose a reason for hiding this comment

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

Curious, what was the reason and what has been done to avoid the random failures?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This file was moved from unit tests. In Unit tests, the mocks changed the AWS creds, and that caused a very weird behavior depending on how unit tests were scheduled. This caused the credentials to be suddenly unmocked!

@leongdl leongdl changed the title feat(JA): WIP - Add force-rehash option to snapshot command. Integ test refactoring. feat(JA): Add force-rehash option to snapshot command. Integ test refactoring. Oct 18, 2024
benl-2023
benl-2023 previously approved these changes Oct 18, 2024
…s for Diff and Snapshot to Integ

Signed-off-by: David Leong <[email protected]>
@leongdl leongdl marked this pull request as ready for review October 18, 2024 16:23
@leongdl leongdl requested a review from a team as a code owner October 18, 2024 16:23
@leongdl
Copy link
Contributor Author

leongdl commented Oct 18, 2024

Could you remove the src/hello file committed from #465?

Doh, this was my test file for snapshot. I snapshot the source code itself.

@leongdl leongdl closed this Oct 18, 2024
@leongdl leongdl reopened this Oct 18, 2024
@leongdl leongdl enabled auto-merge (rebase) October 18, 2024 16:41
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
12.9% Duplication on New Code (required ≤ 3%)

See analysis details on SonarCloud

@leongdl leongdl merged commit 276edae into aws-deadline:mainline Oct 18, 2024
31 of 32 checks passed
@leongdl leongdl deleted the ja-diff branch October 18, 2024 16:46
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.

3 participants