From 25b809f75f6d23b974d9b5d2aa8f4a7f0a4e9ad6 Mon Sep 17 00:00:00 2001 From: Justin Sawatzky <132946620+justinsaws@users.noreply.github.com> Date: Mon, 10 Feb 2025 16:13:43 -0600 Subject: [PATCH] style: switch to ruff formatting (#595) Signed-off-by: Justin Sawatzky <132946620+justinsaws@users.noreply.github.com> --- .github/scripts/get_latest_changelog.py | 1 + hatch.toml | 6 +- pyproject.toml | 2 - requirements-testing.txt | 2 - scripts/pyinstaller/deadline.py | 1 + scripts/pyinstaller/make_exe.py | 1 + src/deadline/__main__.py | 1 + src/deadline/client/api/_queue_parameters.py | 6 +- src/deadline/client/api/_session.py | 1 + src/deadline/client/api/_submit_job_bundle.py | 1 + src/deadline/client/cli/_common.py | 1 + .../client/cli/_groups/attachment_group.py | 1 + src/deadline/client/cli/_groups/auth_group.py | 1 + .../client/cli/_groups/bundle_group.py | 1 + src/deadline/client/cli/_groups/job_group.py | 2 +- .../client/cli/_groups/manifest_group.py | 1 + .../client/cli/deadline_dev_gui_main.py | 1 + src/deadline/client/config/__init__.py | 1 + src/deadline/client/job_bundle/submission.py | 1 + .../client/ui/dataclasses/__init__.py | 3 +- .../ui/deadline_authentication_status.py | 3 +- .../ui/dialogs/submit_job_progress_dialog.py | 1 + .../dialogs/submit_job_to_deadline_dialog.py | 1 + .../client/ui/job_bundle_submitter.py | 4 +- .../client/ui/widgets/cli_job_settings_tab.py | 1 + .../deadline_authentication_status_widget.py | 1 + .../ui/widgets/host_requirements_tab.py | 1 + .../client/ui/widgets/job_attachments_tab.py | 1 + .../ui/widgets/job_bundle_settings_tab.py | 1 + .../ui/widgets/openjd_parameters_widget.py | 1 + .../ui/widgets/shared_job_settings_tab.py | 1 + .../job_attachments/_aws/aws_clients.py | 1 + .../job_attachments/_aws/aws_config.py | 1 + src/deadline/job_attachments/_aws/deadline.py | 1 + src/deadline/job_attachments/api/manifest.py | 1 - .../asset_manifests/_canonical_json.py | 3 +- .../asset_manifests/base_manifest.py | 3 +- .../job_attachments/asset_manifests/decode.py | 3 +- .../asset_manifests/hash_algorithms.py | 2 +- .../asset_manifests/manifest_model.py | 3 +- .../v2023_03_03/asset_manifest.py | 3 +- .../asset_manifests/versions.py | 2 +- src/deadline/job_attachments/asset_sync.py | 3 +- .../job_attachments/caches/hash_cache.py | 4 +- .../job_attachments/caches/s3_check_cache.py | 4 +- src/deadline/job_attachments/download.py | 4 +- src/deadline/job_attachments/exceptions.py | 1 - src/deadline/job_attachments/models.py | 1 + src/deadline/job_attachments/upload.py | 1 + test/integ/cli/test_cli_attachment.py | 27 ++++----- test/integ/cli/test_cli_farm.py | 2 - test/integ/cli/test_cli_manifest_download.py | 15 +++-- test/integ/cli/test_cli_manifest_snapshot.py | 8 +-- test/integ/cli/test_cli_manifest_upload.py | 2 +- test/integ/cli/test_cli_queue.py | 2 - test/integ/conftest.py | 10 ++-- .../test_job_attachments.py | 1 + .../test_job_bundle_submission_asset_refs.py | 4 +- test/unit/deadline_client/cli/test_cli.py | 1 + .../cli/test_cli_attachment.py | 1 + .../unit/deadline_client/cli/test_cli_auth.py | 5 +- .../deadline_client/cli/test_cli_bundle.py | 33 +++-------- .../unit/deadline_client/cli/test_cli_farm.py | 1 + .../deadline_client/cli/test_cli_fleet.py | 1 + .../cli/test_cli_handle_web_url.py | 1 + test/unit/deadline_client/cli/test_cli_job.py | 21 ++----- .../deadline_client/cli/test_cli_manifest.py | 1 - .../deadline_client/cli/test_cli_queue.py | 1 + .../job_bundle/test_adaptors.py | 2 +- .../job_bundle/test_job_parameters.py | 1 + .../job_bundle/test_job_submission.py | 1 + .../test_validate_user_interface_spec.py | 1 - .../unit/deadline_client/testing_utilities.py | 2 +- ...t_host_requirements_dataclass_serialize.py | 1 + .../ui/widgets/test_host_requirements_tab.py | 16 +++--- .../api/test_attachment.py | 2 - .../api/test_manifest_diff.py | 1 - .../api/test_manifest_download.py | 2 - .../api/test_manifest_merge.py | 1 - .../api/test_manifest_upload.py | 1 - .../api/test_snapshot.py | 1 - .../asset_manifests/test_decode.py | 3 +- .../asset_manifests/test_manifest_model.py | 2 +- .../v2023_03_03/test_asset_manifest.py | 3 +- .../aws/test_aws_clients.py | 1 + .../aws/test_deadline.py | 1 + .../caches/test_caches.py | 6 +- .../unit/deadline_job_attachments/conftest.py | 1 + .../test_asset_sync.py | 57 +++++-------------- .../deadline_job_attachments/test_download.py | 21 ++----- .../deadline_job_attachments/test_upload.py | 40 ++++--------- .../unit/deadline_job_attachments/test_vfs.py | 9 +-- 92 files changed, 171 insertions(+), 234 deletions(-) diff --git a/.github/scripts/get_latest_changelog.py b/.github/scripts/get_latest_changelog.py index 5616efbc..2382f587 100644 --- a/.github/scripts/get_latest_changelog.py +++ b/.github/scripts/get_latest_changelog.py @@ -29,6 +29,7 @@ ``` """ + import re h2 = r"^##\s.*$" diff --git a/hatch.toml b/hatch.toml index 5651bc1f..da1f350d 100644 --- a/hatch.toml +++ b/hatch.toml @@ -10,10 +10,10 @@ test_docker = "./scripts/run_sudo_tests.sh --build" typing = "mypy {args:src test} --always-false=PYQT5 --always-false=PYSIDE2 --always-false=PYQT6 --always-true=PYSIDE6" style = [ "ruff check {args:.}", - "black --check --diff {args:.}", + "ruff format --check --diff {args:.}", ] fmt = [ - "black {args:.}", + "ruff format {args:.}", "style", ] lint = [ @@ -21,7 +21,7 @@ lint = [ "typing", ] quality = [ - "black {args:.}", + "ruff format {args:.}", "typing", "style", ] diff --git a/pyproject.toml b/pyproject.toml index ce66d237..27684e1b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -148,8 +148,6 @@ known-first-party = [ # This causes imports to come after regular Python statements causing flake8 rule E402 to be flagged "src/deadline/job_attachments/_windows/*.py" = ["E402"] -[tool.black] -line-length = 100 # Configuration for pytest; enable coverage for deadline_worker_agent, emit # XML, HTML, and terminal reports. diff --git a/requirements-testing.txt b/requirements-testing.txt index 750b2907..a6814fce 100644 --- a/requirements-testing.txt +++ b/requirements-testing.txt @@ -9,8 +9,6 @@ freezegun == 1.* types-pyyaml == 6.* twine == 4.*; python_version == '3.7' twine == 6.*; python_version > '3.7' -black == 24.8.*; python_version == '3.8' -black == 24.10.*; python_version > '3.8' mypy == 1.13.*; python_version == '3.7' mypy == 1.*; python_version > '3.7' ruff == 0.9.* diff --git a/scripts/pyinstaller/deadline.py b/scripts/pyinstaller/deadline.py index dc181eb6..0599f82a 100644 --- a/scripts/pyinstaller/deadline.py +++ b/scripts/pyinstaller/deadline.py @@ -8,6 +8,7 @@ This file should be built with PyInstaller into its own executable which depends on the actual `deadline` package's PyInstaller executable. """ + import pathlib import subprocess import sys diff --git a/scripts/pyinstaller/make_exe.py b/scripts/pyinstaller/make_exe.py index 14d29385..5fc1f78a 100644 --- a/scripts/pyinstaller/make_exe.py +++ b/scripts/pyinstaller/make_exe.py @@ -12,6 +12,7 @@ $ pip install -e . $ python scripts/pyinstaller/make_exe.py """ + import argparse import os import shutil diff --git a/src/deadline/__main__.py b/src/deadline/__main__.py index bf38504d..aa424198 100644 --- a/src/deadline/__main__.py +++ b/src/deadline/__main__.py @@ -3,6 +3,7 @@ """ This file makes "python -m deadline ..." equivalent to "deadline ..." """ + import sys from .client.cli import main diff --git a/src/deadline/client/api/_queue_parameters.py b/src/deadline/client/api/_queue_parameters.py index 8fbad584..ea56b59a 100644 --- a/src/deadline/client/api/_queue_parameters.py +++ b/src/deadline/client/api/_queue_parameters.py @@ -59,9 +59,9 @@ def get_queue_parameter_definitions( parameter["userInterface"] = { "control": get_ui_control_for_parameter_definition(parameter) } - parameter["userInterface"][ - "groupLabel" - ] = f"Queue Environment: {template['environment']['name']}" + parameter["userInterface"]["groupLabel"] = ( + f"Queue Environment: {template['environment']['name']}" + ) existing_parameter = queue_parameters_definitions.get(parameter["name"]) if existing_parameter: differences = parameter_definition_difference(existing_parameter, parameter) diff --git a/src/deadline/client/api/_session.py b/src/deadline/client/api/_session.py index c676ec4a..3dc3e047 100644 --- a/src/deadline/client/api/_session.py +++ b/src/deadline/client/api/_session.py @@ -4,6 +4,7 @@ Provides functionality for boto3 Sessions, Clients, and properties of the Deadline-configured IAM credentials. """ + from __future__ import annotations import logging diff --git a/src/deadline/client/api/_submit_job_bundle.py b/src/deadline/client/api/_submit_job_bundle.py index 43cb2f45..7ba992c6 100644 --- a/src/deadline/client/api/_submit_job_bundle.py +++ b/src/deadline/client/api/_submit_job_bundle.py @@ -3,6 +3,7 @@ """ Provides the function to submit a job bundle to AWS Deadline Cloud. """ + from __future__ import annotations import json diff --git a/src/deadline/client/cli/_common.py b/src/deadline/client/cli/_common.py index a345de66..17a21c78 100644 --- a/src/deadline/client/cli/_common.py +++ b/src/deadline/client/cli/_common.py @@ -3,6 +3,7 @@ """ Functionality common to all the CLI groups. """ + __all__ = [ "_PROMPT_WHEN_COMPLETE", "_prompt_at_completion", diff --git a/src/deadline/client/cli/_groups/attachment_group.py b/src/deadline/client/cli/_groups/attachment_group.py index e52102cb..7092e815 100644 --- a/src/deadline/client/cli/_groups/attachment_group.py +++ b/src/deadline/client/cli/_groups/attachment_group.py @@ -5,6 +5,7 @@ * upload * download """ + from __future__ import annotations import click diff --git a/src/deadline/client/cli/_groups/auth_group.py b/src/deadline/client/cli/_groups/auth_group.py index c9bd38c7..12031afc 100644 --- a/src/deadline/client/cli/_groups/auth_group.py +++ b/src/deadline/client/cli/_groups/auth_group.py @@ -6,6 +6,7 @@ * logout * status """ + import click import json import logging diff --git a/src/deadline/client/cli/_groups/bundle_group.py b/src/deadline/client/cli/_groups/bundle_group.py index c9709811..7b03ffc1 100644 --- a/src/deadline/client/cli/_groups/bundle_group.py +++ b/src/deadline/client/cli/_groups/bundle_group.py @@ -3,6 +3,7 @@ """ All the `deadline bundle` commands. """ + from __future__ import annotations import json diff --git a/src/deadline/client/cli/_groups/job_group.py b/src/deadline/client/cli/_groups/job_group.py index c1d2b34e..dc0fde75 100644 --- a/src/deadline/client/cli/_groups/job_group.py +++ b/src/deadline/client/cli/_groups/job_group.py @@ -500,7 +500,7 @@ def _get_summary_of_files_to_download_message( f"{os.path.commonpath([os.path.join(directory, p) for p in output_paths])} ({len(output_paths)} file{'s' if len(output_paths) > 1 else ''})" for directory, output_paths in output_paths_by_root.items() ) - return "\n" "Summary of files to download:\n" f"{paths_message_joined}" "\n" + return f"\nSummary of files to download:\n{paths_message_joined}\n" def _get_roots_list_message(asset_roots: list[str], is_json_format: bool) -> str: diff --git a/src/deadline/client/cli/_groups/manifest_group.py b/src/deadline/client/cli/_groups/manifest_group.py index f6435fad..d8925cf3 100644 --- a/src/deadline/client/cli/_groups/manifest_group.py +++ b/src/deadline/client/cli/_groups/manifest_group.py @@ -7,6 +7,7 @@ * diff * download """ + from __future__ import annotations from configparser import ConfigParser diff --git a/src/deadline/client/cli/deadline_dev_gui_main.py b/src/deadline/client/cli/deadline_dev_gui_main.py index 9868f3fc..dc5a75ba 100644 --- a/src/deadline/client/cli/deadline_dev_gui_main.py +++ b/src/deadline/client/cli/deadline_dev_gui_main.py @@ -5,6 +5,7 @@ Runs the Deadline Dev GUI. Can be run as a python script file. """ + from ..config import get_setting diff --git a/src/deadline/client/config/__init__.py b/src/deadline/client/config/__init__.py index ccacb056..17944fdc 100644 --- a/src/deadline/client/config/__init__.py +++ b/src/deadline/client/config/__init__.py @@ -7,6 +7,7 @@ the environment variable DEADLINE_CONFIG_FILE_PATH, it is used as the configuration file path instead. """ + __all__ = [ "get_setting_default", "get_setting", diff --git a/src/deadline/client/job_bundle/submission.py b/src/deadline/client/job_bundle/submission.py index e754dd0f..7bbde6aa 100644 --- a/src/deadline/client/job_bundle/submission.py +++ b/src/deadline/client/job_bundle/submission.py @@ -3,6 +3,7 @@ """ Helper functions to enable submission of a Job Bundle to CreateJob """ + from __future__ import annotations import dataclasses import logging diff --git a/src/deadline/client/ui/dataclasses/__init__.py b/src/deadline/client/ui/dataclasses/__init__.py index 47a896f3..c190a3bb 100644 --- a/src/deadline/client/ui/dataclasses/__init__.py +++ b/src/deadline/client/ui/dataclasses/__init__.py @@ -3,6 +3,7 @@ """ Contains dataclasses for holding UI parameter values, used by the widgets. """ + from __future__ import annotations import os @@ -290,7 +291,7 @@ def _validate_amount(amount: Union[dict, CustomAmountRequirement]) -> CustomAmou @staticmethod def _validate_attribute( - attribute: Union[dict, CustomAttributeRequirement] + attribute: Union[dict, CustomAttributeRequirement], ) -> CustomAttributeRequirement: if isinstance(attribute, dict): attribute = CustomAttributeRequirement(**attribute) diff --git a/src/deadline/client/ui/deadline_authentication_status.py b/src/deadline/client/ui/deadline_authentication_status.py index a0bfa2fd..b75e4c77 100644 --- a/src/deadline/client/ui/deadline_authentication_status.py +++ b/src/deadline/client/ui/deadline_authentication_status.py @@ -1,7 +1,7 @@ # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. """ -Provides an object that can be used to track current status of AWS Deadline Cloud +Provides an object that can be used to track current status of AWS Deadline Cloud authentication. The object emits the following Qt Signals: @@ -20,6 +20,7 @@ This is checked by looking for the relevant properties in the AWS profile configuration. """ + import os import threading from configparser import ConfigParser diff --git a/src/deadline/client/ui/dialogs/submit_job_progress_dialog.py b/src/deadline/client/ui/dialogs/submit_job_progress_dialog.py index f5e06839..a5f04382 100644 --- a/src/deadline/client/ui/dialogs/submit_job_progress_dialog.py +++ b/src/deadline/client/ui/dialogs/submit_job_progress_dialog.py @@ -3,6 +3,7 @@ Provides a modal dialog box for the submission progress when submitting to AWS Deadline Cloud """ + from __future__ import annotations import json diff --git a/src/deadline/client/ui/dialogs/submit_job_to_deadline_dialog.py b/src/deadline/client/ui/dialogs/submit_job_to_deadline_dialog.py index b8bd24b5..dc381e28 100644 --- a/src/deadline/client/ui/dialogs/submit_job_to_deadline_dialog.py +++ b/src/deadline/client/ui/dialogs/submit_job_to_deadline_dialog.py @@ -1,6 +1,7 @@ # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. """UI Components for the Render Submitter""" + from __future__ import annotations import logging diff --git a/src/deadline/client/ui/job_bundle_submitter.py b/src/deadline/client/ui/job_bundle_submitter.py index 057a004b..91c94700 100644 --- a/src/deadline/client/ui/job_bundle_submitter.py +++ b/src/deadline/client/ui/job_bundle_submitter.py @@ -62,7 +62,9 @@ def show_job_bundle_submitter( # Get the main application window so we can parent ours to it app = QApplication.instance() main_windows = [ - widget for widget in app.topLevelWidgets() if isinstance(widget, QMainWindow) # type: ignore[union-attr] + widget + for widget in app.topLevelWidgets() + if isinstance(widget, QMainWindow) # type: ignore[union-attr] ] if main_windows: parent = main_windows[0] diff --git a/src/deadline/client/ui/widgets/cli_job_settings_tab.py b/src/deadline/client/ui/widgets/cli_job_settings_tab.py index e70e5a5b..2e8d6e26 100644 --- a/src/deadline/client/ui/widgets/cli_job_settings_tab.py +++ b/src/deadline/client/ui/widgets/cli_job_settings_tab.py @@ -3,6 +3,7 @@ """ UI widgets for the Scene Settings tab. """ + import os from qtpy.QtCore import Qt # type: ignore diff --git a/src/deadline/client/ui/widgets/deadline_authentication_status_widget.py b/src/deadline/client/ui/widgets/deadline_authentication_status_widget.py index 250dbd2f..1d7f7c18 100644 --- a/src/deadline/client/ui/widgets/deadline_authentication_status_widget.py +++ b/src/deadline/client/ui/widgets/deadline_authentication_status_widget.py @@ -5,6 +5,7 @@ the current status of AWS Deadline Cloud authentication and API. The current status is handled by DeadlineAuthenticationStatus. """ + from logging import getLogger from typing import Optional diff --git a/src/deadline/client/ui/widgets/host_requirements_tab.py b/src/deadline/client/ui/widgets/host_requirements_tab.py index 9d218516..e49fbf78 100644 --- a/src/deadline/client/ui/widgets/host_requirements_tab.py +++ b/src/deadline/client/ui/widgets/host_requirements_tab.py @@ -3,6 +3,7 @@ """ UI widgets for the host requirements tab. """ + import re from logging import getLogger from pathlib import Path diff --git a/src/deadline/client/ui/widgets/job_attachments_tab.py b/src/deadline/client/ui/widgets/job_attachments_tab.py index 0e942a26..b764bcb5 100644 --- a/src/deadline/client/ui/widgets/job_attachments_tab.py +++ b/src/deadline/client/ui/widgets/job_attachments_tab.py @@ -3,6 +3,7 @@ """ UI widgets for the job attachments tab. """ + from __future__ import annotations import os from logging import getLogger diff --git a/src/deadline/client/ui/widgets/job_bundle_settings_tab.py b/src/deadline/client/ui/widgets/job_bundle_settings_tab.py index 02f5d4d2..0e13e4d1 100644 --- a/src/deadline/client/ui/widgets/job_bundle_settings_tab.py +++ b/src/deadline/client/ui/widgets/job_bundle_settings_tab.py @@ -3,6 +3,7 @@ """ UI widgets for the scene settings tab. """ + from __future__ import annotations import os diff --git a/src/deadline/client/ui/widgets/openjd_parameters_widget.py b/src/deadline/client/ui/widgets/openjd_parameters_widget.py index bae3ae88..1e2fd74e 100644 --- a/src/deadline/client/ui/widgets/openjd_parameters_widget.py +++ b/src/deadline/client/ui/widgets/openjd_parameters_widget.py @@ -2,6 +2,7 @@ """ UI widgets for the Scene Settings tab. """ + from __future__ import annotations import os diff --git a/src/deadline/client/ui/widgets/shared_job_settings_tab.py b/src/deadline/client/ui/widgets/shared_job_settings_tab.py index 606402f1..9a62abac 100644 --- a/src/deadline/client/ui/widgets/shared_job_settings_tab.py +++ b/src/deadline/client/ui/widgets/shared_job_settings_tab.py @@ -3,6 +3,7 @@ """ A UI Widget containing the render setup tab """ + from __future__ import annotations import sys diff --git a/src/deadline/job_attachments/_aws/aws_clients.py b/src/deadline/job_attachments/_aws/aws_clients.py index 4a603216..b8568e55 100644 --- a/src/deadline/job_attachments/_aws/aws_clients.py +++ b/src/deadline/job_attachments/_aws/aws_clients.py @@ -1,6 +1,7 @@ # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. """Functions for handling and retrieving AWS clients.""" + from __future__ import annotations from functools import lru_cache diff --git a/src/deadline/job_attachments/_aws/aws_config.py b/src/deadline/job_attachments/_aws/aws_config.py index 489c8e04..29820456 100644 --- a/src/deadline/job_attachments/_aws/aws_config.py +++ b/src/deadline/job_attachments/_aws/aws_config.py @@ -1,6 +1,7 @@ # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. """AWS configuration.""" + VENDOR_CODE: str = "deadline" # S3 related diff --git a/src/deadline/job_attachments/_aws/deadline.py b/src/deadline/job_attachments/_aws/deadline.py index bbcbbe10..42e3fb41 100644 --- a/src/deadline/job_attachments/_aws/deadline.py +++ b/src/deadline/job_attachments/_aws/deadline.py @@ -1,6 +1,7 @@ # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. """Functions for interfacing with Deadline API calls.""" + from typing import Optional import boto3 diff --git a/src/deadline/job_attachments/api/manifest.py b/src/deadline/job_attachments/api/manifest.py index cbbb80cc..fbb3ef9a 100644 --- a/src/deadline/job_attachments/api/manifest.py +++ b/src/deadline/job_attachments/api/manifest.py @@ -92,7 +92,6 @@ def _manifest_snapshot( force_rehash: bool = False, logger: ClickLogger = ClickLogger(False), ) -> Optional[ManifestSnapshot]: - # Get all files in the root. glob_config: GlobConfig if include or exclude: diff --git a/src/deadline/job_attachments/asset_manifests/_canonical_json.py b/src/deadline/job_attachments/asset_manifests/_canonical_json.py index f043fb87..2bb1e57b 100644 --- a/src/deadline/job_attachments/asset_manifests/_canonical_json.py +++ b/src/deadline/job_attachments/asset_manifests/_canonical_json.py @@ -1,6 +1,7 @@ # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -""" Module that defines the second iteration of the asset manifest """ +"""Module that defines the second iteration of the asset manifest""" + from __future__ import annotations import dataclasses diff --git a/src/deadline/job_attachments/asset_manifests/base_manifest.py b/src/deadline/job_attachments/asset_manifests/base_manifest.py index ac35160b..7cad314d 100644 --- a/src/deadline/job_attachments/asset_manifests/base_manifest.py +++ b/src/deadline/job_attachments/asset_manifests/base_manifest.py @@ -1,6 +1,7 @@ # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -""" Contains the base asset manifest and entities that are part of the Asset Manifest """ +"""Contains the base asset manifest and entities that are part of the Asset Manifest""" + from __future__ import annotations from abc import ABC, abstractmethod diff --git a/src/deadline/job_attachments/asset_manifests/decode.py b/src/deadline/job_attachments/asset_manifests/decode.py index 9a229d11..88a1ab74 100644 --- a/src/deadline/job_attachments/asset_manifests/decode.py +++ b/src/deadline/job_attachments/asset_manifests/decode.py @@ -1,6 +1,7 @@ # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -""" Contains methods for decoding and validating Asset Manifests. """ +"""Contains methods for decoding and validating Asset Manifests.""" + from __future__ import annotations import json diff --git a/src/deadline/job_attachments/asset_manifests/hash_algorithms.py b/src/deadline/job_attachments/asset_manifests/hash_algorithms.py index 0265ba1a..037500bd 100644 --- a/src/deadline/job_attachments/asset_manifests/hash_algorithms.py +++ b/src/deadline/job_attachments/asset_manifests/hash_algorithms.py @@ -1,6 +1,6 @@ # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -""" Module that defines the hashing algorithms supported by this library. """ +"""Module that defines the hashing algorithms supported by this library.""" import io diff --git a/src/deadline/job_attachments/asset_manifests/manifest_model.py b/src/deadline/job_attachments/asset_manifests/manifest_model.py index f936dce3..80b204c5 100644 --- a/src/deadline/job_attachments/asset_manifests/manifest_model.py +++ b/src/deadline/job_attachments/asset_manifests/manifest_model.py @@ -1,6 +1,7 @@ # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -""" Module for the base Manifest Model. """ +"""Module for the base Manifest Model.""" + from __future__ import annotations from typing import Type diff --git a/src/deadline/job_attachments/asset_manifests/v2023_03_03/asset_manifest.py b/src/deadline/job_attachments/asset_manifests/v2023_03_03/asset_manifest.py index 63a15228..f825328f 100644 --- a/src/deadline/job_attachments/asset_manifests/v2023_03_03/asset_manifest.py +++ b/src/deadline/job_attachments/asset_manifests/v2023_03_03/asset_manifest.py @@ -1,6 +1,7 @@ # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -""" Module that defines the v2023-03-03 version of the asset manifest """ +"""Module that defines the v2023-03-03 version of the asset manifest""" + from __future__ import annotations from dataclasses import dataclass diff --git a/src/deadline/job_attachments/asset_manifests/versions.py b/src/deadline/job_attachments/asset_manifests/versions.py index 9ccb1da0..cab84b67 100644 --- a/src/deadline/job_attachments/asset_manifests/versions.py +++ b/src/deadline/job_attachments/asset_manifests/versions.py @@ -1,6 +1,6 @@ # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -""" Module that defines the asset manifest versions. """ +"""Module that defines the asset manifest versions.""" from enum import Enum diff --git a/src/deadline/job_attachments/asset_sync.py b/src/deadline/job_attachments/asset_sync.py index e36d3883..78f1ffd9 100644 --- a/src/deadline/job_attachments/asset_sync.py +++ b/src/deadline/job_attachments/asset_sync.py @@ -1,6 +1,7 @@ # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -""" Module for File Attachment synching """ +"""Module for File Attachment synching""" + from __future__ import annotations from dataclasses import asdict import os diff --git a/src/deadline/job_attachments/caches/hash_cache.py b/src/deadline/job_attachments/caches/hash_cache.py index b3f10d5e..689180b1 100644 --- a/src/deadline/job_attachments/caches/hash_cache.py +++ b/src/deadline/job_attachments/caches/hash_cache.py @@ -51,9 +51,7 @@ class HashCache(CacheDB): def __init__(self, cache_dir: Optional[str] = None) -> None: table_name: str = f"hashesV{self.CACHE_DB_VERSION}" - create_query: str = ( - f"CREATE TABLE hashesV{self.CACHE_DB_VERSION}(file_path blob primary key, hash_algorithm text secondary key, file_hash text, last_modified_time timestamp)" - ) + create_query: str = f"CREATE TABLE hashesV{self.CACHE_DB_VERSION}(file_path blob primary key, hash_algorithm text secondary key, file_hash text, last_modified_time timestamp)" super().__init__( cache_name=self.CACHE_NAME, table_name=table_name, diff --git a/src/deadline/job_attachments/caches/s3_check_cache.py b/src/deadline/job_attachments/caches/s3_check_cache.py index abff4f3a..fdb9b87f 100644 --- a/src/deadline/job_attachments/caches/s3_check_cache.py +++ b/src/deadline/job_attachments/caches/s3_check_cache.py @@ -48,9 +48,7 @@ class S3CheckCache(CacheDB): def __init__(self, cache_dir: Optional[str] = None) -> None: table_name: str = f"s3checkV{self.CACHE_DB_VERSION}" - create_query: str = ( - f"CREATE TABLE s3checkV{self.CACHE_DB_VERSION}(s3_key text primary key, last_seen_time timestamp)" - ) + create_query: str = f"CREATE TABLE s3checkV{self.CACHE_DB_VERSION}(s3_key text primary key, last_seen_time timestamp)" super().__init__( cache_name=self.CACHE_NAME, table_name=table_name, diff --git a/src/deadline/job_attachments/download.py b/src/deadline/job_attachments/download.py index 8964f783..8a0f69fa 100644 --- a/src/deadline/job_attachments/download.py +++ b/src/deadline/job_attachments/download.py @@ -1,6 +1,7 @@ # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. """Functions for downloading output from the Job Attachment CAS.""" + from __future__ import annotations import concurrent.futures @@ -1024,7 +1025,8 @@ def mount_vfs_from_manifests( for mount_point, manifest in manifests_by_root.items(): # Validate the file paths to see if they are under the given download directory. _ensure_paths_within_directory( - mount_point, [path.path for path in manifest.paths] # type: ignore + mount_point, + [path.path for path in manifest.paths], # type: ignore ) final_manifest: BaseAssetManifest = handle_existing_vfs( manifest=manifest, diff --git a/src/deadline/job_attachments/exceptions.py b/src/deadline/job_attachments/exceptions.py index 725f5baf..64a380d0 100644 --- a/src/deadline/job_attachments/exceptions.py +++ b/src/deadline/job_attachments/exceptions.py @@ -4,7 +4,6 @@ Exceptions that the Deadline Job Attachments library can raise. """ - from typing import Optional from deadline.job_attachments.progress_tracker import SummaryStatistics diff --git a/src/deadline/job_attachments/models.py b/src/deadline/job_attachments/models.py index 6693518c..fb6c5627 100644 --- a/src/deadline/job_attachments/models.py +++ b/src/deadline/job_attachments/models.py @@ -3,6 +3,7 @@ """ Data classes for AWS objects. """ + from __future__ import annotations import sys diff --git a/src/deadline/job_attachments/upload.py b/src/deadline/job_attachments/upload.py index 590db3ab..ce7b4320 100644 --- a/src/deadline/job_attachments/upload.py +++ b/src/deadline/job_attachments/upload.py @@ -3,6 +3,7 @@ """ Classes for handling uploading of assets. """ + from __future__ import annotations import concurrent.futures diff --git a/test/integ/cli/test_cli_attachment.py b/test/integ/cli/test_cli_attachment.py index 85f3aeaf..feabf89f 100644 --- a/test/integ/cli/test_cli_attachment.py +++ b/test/integ/cli/test_cli_attachment.py @@ -56,7 +56,6 @@ class TestAttachment: - @pytest.fixture def temp_dir(self): with tempfile.TemporaryDirectory() as tmpdir_path: @@ -122,9 +121,9 @@ def test_attachment_s3_cross_account_access_denied(self, external_bucket, temp_d f"s3://{external_bucket}/test", ], ) - assert ( - result.exit_code != 0 - ), f"Expecting cross-account s3 access to fail but not, CLI output {result.output}" + assert result.exit_code != 0, ( + f"Expecting cross-account s3 access to fail but not, CLI output {result.output}" + ) assert "deadline.job_attachments.exceptions.JobAttachmentsS3ClientError" in result.output assert "HTTP Status Code: 403, Access denied." in result.output @@ -141,16 +140,15 @@ def test_attachment_s3_cross_account_access_denied(self, external_bucket, temp_d f"s3://{external_bucket}/test", ], ) - assert ( - result.exit_code != 0 - ), f"Expecting cross-account s3 access to fail but not, CLI output {result.output}" + assert result.exit_code != 0, ( + f"Expecting cross-account s3 access to fail but not, CLI output {result.output}" + ) assert "deadline.job_attachments.exceptions.JobAttachmentsS3ClientError" in result.output assert "HTTP Status Code: 403, Forbidden or Access denied." in result.output @pytest.mark.integ @pytest.mark.parametrize("manifest_case_key", MOCK_MANIFEST_CASE.keys()) def test_attachment_basic_flow(self, temp_dir, job_attachment_resources, manifest_case_key): - # Given file_name: str = f"{hash_data(temp_dir.encode('utf-8'), HashAlgorithm.XXH128)}_output" manifest_path: str = os.path.join(temp_dir, file_name) @@ -205,9 +203,9 @@ def test_attachment_basic_flow(self, temp_dir, job_attachment_resources, manifes assert json.loads(result.output)["processed_bytes"] == len( MOCK_FILE_CASE[manifest_case_key] ) - assert file_name in os.listdir( - os.getcwd() - ), "Expecting downloaded folder named with data hash created in the working directory with downloaded files but not." + assert file_name in os.listdir(os.getcwd()), ( + "Expecting downloaded folder named with data hash created in the working directory with downloaded files but not." + ) asset_files = os.listdir(os.path.join(os.getcwd(), file_name, "files")) assert len(asset_files) == 1 @@ -216,7 +214,6 @@ def test_attachment_basic_flow(self, temp_dir, job_attachment_resources, manifes def test_attachment_path_mapping_flow( self, temp_dir, job_attachment_resources, manifest_case_key ): - # Given source_path: str = os.path.join(temp_dir, "virtual_source") destination_path: str = temp_dir @@ -294,6 +291,6 @@ def test_attachment_path_mapping_flow( ) asset_files = os.listdir(os.path.join(destination_path, "files")) - assert ( - len(asset_files) == 3 - ), f"Expecting 3 asset files, 2 from upload and 1 from download, but got {len(asset_files)}." + assert len(asset_files) == 3, ( + f"Expecting 3 asset files, 2 from upload and 1 from download, but got {len(asset_files)}." + ) diff --git a/test/integ/cli/test_cli_farm.py b/test/integ/cli/test_cli_farm.py index 4b1373bd..2e6f6027 100644 --- a/test/integ/cli/test_cli_farm.py +++ b/test/integ/cli/test_cli_farm.py @@ -7,7 +7,6 @@ def test_farm_get(deadline_cli_test: DeadlineCliTest) -> None: - runner = CliRunner() result = runner.invoke( @@ -25,7 +24,6 @@ def test_farm_get(deadline_cli_test: DeadlineCliTest) -> None: def test_farm_list(deadline_cli_test: DeadlineCliTest) -> None: - runner = CliRunner() result = runner.invoke( diff --git a/test/integ/cli/test_cli_manifest_download.py b/test/integ/cli/test_cli_manifest_download.py index 502a6fe1..64601ac8 100644 --- a/test/integ/cli/test_cli_manifest_download.py +++ b/test/integ/cli/test_cli_manifest_download.py @@ -3,6 +3,7 @@ """ Integ tests for the CLI manifest download commands. """ + import json import tempfile import time @@ -25,7 +26,6 @@ @pytest.mark.integ class TestManifestDownload: - @pytest.fixture def temp_dir(self): with tempfile.TemporaryDirectory() as tmpdir_path: @@ -181,9 +181,9 @@ def test_manifest_download_job( result = runner.invoke(main, args) # Then - assert ( - result.exit_code == 0 - ), f"{result.output}, {job_attachment_test.farm_id}, {job_attachment_test.queue_id}" + assert result.exit_code == 0, ( + f"{result.output}, {job_attachment_test.farm_id}, {job_attachment_test.queue_id}" + ) if json_output: # If JSON mode was specified, make sure the output is JSON and contains the downloaded manifest file. download = json.loads(result.output) @@ -216,7 +216,6 @@ def test_manifest_download_job_step_dependency( default_job_template_step_step_dependency: str, job_attachment_test: JobAttachmentTest, ): - # Create a job, with step step dependency. job_id: str = self._setup_create_job( upload_input_files_one_asset_in_cas, @@ -251,9 +250,9 @@ def test_manifest_download_job_step_dependency( result = runner.invoke(main, args) # Then - assert ( - result.exit_code == 0 - ), f"{result.output}, {job_attachment_test.farm_id}, {job_attachment_test.queue_id}" + assert result.exit_code == 0, ( + f"{result.output}, {job_attachment_test.farm_id}, {job_attachment_test.queue_id}" + ) if json_output: # If JSON mode was specified, make sure the output is JSON and contains the downloaded manifest file. download = json.loads(result.output) diff --git a/test/integ/cli/test_cli_manifest_snapshot.py b/test/integ/cli/test_cli_manifest_snapshot.py index a4ada749..633eddf6 100644 --- a/test/integ/cli/test_cli_manifest_snapshot.py +++ b/test/integ/cli/test_cli_manifest_snapshot.py @@ -3,6 +3,7 @@ """ Integ tests for the CLI asset commands. """ + import json import os from pathlib import Path @@ -14,7 +15,6 @@ class TestManifestSnapshot: - @pytest.fixture def temp_dir(self): with tempfile.TemporaryDirectory() as tmpdir_path: @@ -55,9 +55,9 @@ def _create_test_manifest(self, tmp_path: str, root_dir: str) -> str: assert result.exit_code == 0, result.output manifest_files = os.listdir(manifest_dir) - assert ( - len(manifest_files) == 1 - ), f"Expected exactly one manifest file, but got {len(manifest_files)}" + assert len(manifest_files) == 1, ( + f"Expected exactly one manifest file, but got {len(manifest_files)}" + ) manifest = manifest_files[0] assert "test" in manifest, f"Expected test in manifest file name, got {manifest}" diff --git a/test/integ/cli/test_cli_manifest_upload.py b/test/integ/cli/test_cli_manifest_upload.py index 50dd560c..8a62bf77 100644 --- a/test/integ/cli/test_cli_manifest_upload.py +++ b/test/integ/cli/test_cli_manifest_upload.py @@ -3,6 +3,7 @@ """ Integ tests for the CLI manifest upload commands. """ + import os from pathlib import Path from typing import Optional @@ -34,7 +35,6 @@ @pytest.mark.integ class TestManifestUpload: - @pytest.fixture def temp_dir(self): with tempfile.TemporaryDirectory() as tmpdir_path: diff --git a/test/integ/cli/test_cli_queue.py b/test/integ/cli/test_cli_queue.py index 40cd12de..257c6d2b 100644 --- a/test/integ/cli/test_cli_queue.py +++ b/test/integ/cli/test_cli_queue.py @@ -7,7 +7,6 @@ def test_queue_get(deadline_cli_test: DeadlineCliTest) -> None: - runner = CliRunner() result = runner.invoke( @@ -34,7 +33,6 @@ def test_queue_get(deadline_cli_test: DeadlineCliTest) -> None: def test_queue_list(deadline_cli_test: DeadlineCliTest) -> None: - runner = CliRunner() result = runner.invoke( diff --git a/test/integ/conftest.py b/test/integ/conftest.py index b33e9bc2..9eb164ae 100644 --- a/test/integ/conftest.py +++ b/test/integ/conftest.py @@ -35,7 +35,7 @@ def default_job_template() -> str: "embeddedFiles": [ { "name": "run", - "data": "#!/bin/env bash\n" "set -ex\n" "echo 'First Step'", + "data": "#!/bin/env bash\nset -ex\necho 'First Step'", "runnable": True, "type": "TEXT", } @@ -54,7 +54,7 @@ def default_job_template() -> str: "embeddedFiles": [ { "name": "run", - "data": "#!/bin/env bash\n" "set -ex\n" "echo 'Second step'", + "data": "#!/bin/env bash\nset -ex\necho 'Second step'", "runnable": True, "type": "TEXT", } @@ -88,7 +88,7 @@ def default_job_template_step_step_dependency() -> str: "embeddedFiles": [ { "name": "run", - "data": "#!/bin/env bash\n" "set -ex\n" "echo 'First Step'", + "data": "#!/bin/env bash\nset -ex\necho 'First Step'", "runnable": True, "type": "TEXT", } @@ -108,7 +108,7 @@ def default_job_template_step_step_dependency() -> str: "embeddedFiles": [ { "name": "run", - "data": "#!/bin/env bash\n" "set -ex\n" "echo 'Second step'", + "data": "#!/bin/env bash\nset -ex\necho 'Second step'", "runnable": True, "type": "TEXT", } @@ -142,7 +142,7 @@ def default_job_template_one_task_one_step() -> str: "embeddedFiles": [ { "name": "run", - "data": "#!/bin/env bash\n" "set -ex\n" "echo 'First Step'", + "data": "#!/bin/env bash\nset -ex\necho 'First Step'", "runnable": True, "type": "TEXT", } diff --git a/test/integ/deadline_job_attachments/test_job_attachments.py b/test/integ/deadline_job_attachments/test_job_attachments.py index d635cc04..22405f72 100644 --- a/test/integ/deadline_job_attachments/test_job_attachments.py +++ b/test/integ/deadline_job_attachments/test_job_attachments.py @@ -1,6 +1,7 @@ # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. """Integration tests for Job Attachments.""" + import logging import os import shutil diff --git a/test/unit/deadline_client/api/test_job_bundle_submission_asset_refs.py b/test/unit/deadline_client/api/test_job_bundle_submission_asset_refs.py index 3e5ea3a3..479a3d99 100644 --- a/test/unit/deadline_client/api/test_job_bundle_submission_asset_refs.py +++ b/test/unit/deadline_client/api/test_job_bundle_submission_asset_refs.py @@ -251,9 +251,7 @@ def test_create_job_from_job_bundle_with_all_asset_ref_variants( _submit_job_bundle.api, "get_boto3_client" ) as client_mock, patch.object( _submit_job_bundle.api, "get_queue_user_boto3_session" - ), patch.object( - S3AssetManager, "prepare_paths_for_upload" - ) as mock_prepare_paths, patch.object( + ), patch.object(S3AssetManager, "prepare_paths_for_upload") as mock_prepare_paths, patch.object( S3AssetManager, "hash_assets_and_create_manifest" ) as mock_hash_assets, patch.object( S3AssetManager, "upload_assets" diff --git a/test/unit/deadline_client/cli/test_cli.py b/test/unit/deadline_client/cli/test_cli.py index 4dceaac9..9b7018da 100644 --- a/test/unit/deadline_client/cli/test_cli.py +++ b/test/unit/deadline_client/cli/test_cli.py @@ -3,6 +3,7 @@ """ Tests for the CLI generally. """ + import subprocess import sys from unittest.mock import patch diff --git a/test/unit/deadline_client/cli/test_cli_attachment.py b/test/unit/deadline_client/cli/test_cli_attachment.py index f9a333d7..7f8c8e0b 100644 --- a/test/unit/deadline_client/cli/test_cli_attachment.py +++ b/test/unit/deadline_client/cli/test_cli_attachment.py @@ -3,6 +3,7 @@ """ Tests for the CLI attachment commands. """ + import os from click.testing import CliRunner diff --git a/test/unit/deadline_client/cli/test_cli_auth.py b/test/unit/deadline_client/cli/test_cli_auth.py index cf8db71f..341ad190 100644 --- a/test/unit/deadline_client/cli/test_cli_auth.py +++ b/test/unit/deadline_client/cli/test_cli_auth.py @@ -3,6 +3,7 @@ """ Tests for the CLI auth commands. """ + import json import subprocess import sys @@ -36,9 +37,7 @@ def test_cli_deadline_cloud_monitor_login_and_logout(fresh_deadline_config): api._session._get_queue_user_boto3_session, "cache_clear" ) as mock_queue_session_cache_clear, patch.object( api, "get_boto3_session", new=session_mock - ), patch.object( - subprocess, "Popen" - ) as popen_mock, patch.object( + ), patch.object(subprocess, "Popen") as popen_mock, patch.object( subprocess, "check_output" ) as check_output_mock: # The profile name diff --git a/test/unit/deadline_client/cli/test_cli_bundle.py b/test/unit/deadline_client/cli/test_cli_bundle.py index da7ba06e..e33cf09e 100644 --- a/test/unit/deadline_client/cli/test_cli_bundle.py +++ b/test/unit/deadline_client/cli/test_cli_bundle.py @@ -3,6 +3,7 @@ """ Tests for the CLI job bundle commands. """ + import os import sys import tempfile @@ -121,13 +122,9 @@ def test_cli_bundle_submit(fresh_deadline_config, temp_job_bundle_dir): _queue_parameters, "get_boto3_client" ) as qp_boto3_client_mock, patch.object( _submit_job_bundle, "_hash_attachments", return_value=[] - ), patch.object( - _submit_job_bundle.api, "get_queue_user_boto3_session" - ), patch.object( + ), patch.object(_submit_job_bundle.api, "get_queue_user_boto3_session"), patch.object( _submit_job_bundle, "_upload_attachments" - ), patch.object( - bundle_group.api, "get_deadline_cloud_library_telemetry_client" - ): + ), patch.object(bundle_group.api, "get_deadline_cloud_library_telemetry_client"): get_boto3_client_mock().create_job.return_value = MOCK_CREATE_JOB_RESPONSE get_boto3_client_mock().get_job.return_value = MOCK_GET_JOB_RESPONSE qp_boto3_client_mock().list_queue_environments.return_value = ( @@ -393,17 +390,11 @@ def test_cli_bundle_asset_load_method(fresh_deadline_config, temp_job_bundle_dir _queue_parameters, "get_boto3_client" ) as qp_boto3_client_mock, patch.object( _submit_job_bundle, "_hash_attachments", return_value=(attachment_mock, {}) - ), patch.object( - _submit_job_bundle, "_upload_attachments", return_value={} - ), patch.object( + ), patch.object(_submit_job_bundle, "_upload_attachments", return_value={}), patch.object( _submit_job_bundle.api, "get_boto3_session" - ), patch.object( - _submit_job_bundle.api, "get_queue_user_boto3_session" - ), patch.object( + ), patch.object(_submit_job_bundle.api, "get_queue_user_boto3_session"), patch.object( bundle_group.api, "get_deadline_cloud_library_telemetry_client" - ), patch.object( - S3AssetManager, "prepare_paths_for_upload", return_value=upload_group_mock - ): + ), patch.object(S3AssetManager, "prepare_paths_for_upload", return_value=upload_group_mock): bundle_boto3_client_mock().create_job.return_value = MOCK_CREATE_JOB_RESPONSE bundle_boto3_client_mock().get_job.return_value = MOCK_GET_JOB_RESPONSE bundle_boto3_client_mock().get_queue.return_value = { @@ -698,15 +689,11 @@ def test_cli_bundle_accept_upload_confirmation(fresh_deadline_config, temp_job_b _submit_job_bundle.api, "get_boto3_client" ) as get_boto3_client_mock, patch.object( _submit_job_bundle, "_hash_attachments", return_value=[SummaryStatistics(), "test"] - ), patch.object( - _submit_job_bundle, "_upload_attachments" - ), patch.object( + ), patch.object(_submit_job_bundle, "_upload_attachments"), patch.object( _submit_job_bundle.api, "get_boto3_session" ), patch.object( _submit_job_bundle.api, "get_queue_parameter_definitions", return_value=[] - ), patch.object( - _submit_job_bundle.api, "get_queue_user_boto3_session" - ), patch.object( + ), patch.object(_submit_job_bundle.api, "get_queue_user_boto3_session"), patch.object( bundle_group.api, "get_deadline_cloud_library_telemetry_client" ): get_boto3_client_mock().create_job.return_value = MOCK_CREATE_JOB_RESPONSE @@ -780,9 +767,7 @@ def test_cli_bundle_reject_upload_confirmation(fresh_deadline_config, temp_job_b _submit_job_bundle, "_upload_attachments" ) as upload_attachments_mock, patch.object( _submit_job_bundle.api, "get_boto3_session" - ), patch.object( - _submit_job_bundle.api, "get_queue_user_boto3_session" - ), patch.object( + ), patch.object(_submit_job_bundle.api, "get_queue_user_boto3_session"), patch.object( bundle_group.api, "get_deadline_cloud_library_telemetry_client" ): get_boto3_client_mock().get_queue.return_value = { diff --git a/test/unit/deadline_client/cli/test_cli_farm.py b/test/unit/deadline_client/cli/test_cli_farm.py index b4d8f253..650139d2 100644 --- a/test/unit/deadline_client/cli/test_cli_farm.py +++ b/test/unit/deadline_client/cli/test_cli_farm.py @@ -3,6 +3,7 @@ """ Tests for the CLI farm commands. """ + from unittest.mock import patch import os diff --git a/test/unit/deadline_client/cli/test_cli_fleet.py b/test/unit/deadline_client/cli/test_cli_fleet.py index 7049e732..6e7c10fc 100644 --- a/test/unit/deadline_client/cli/test_cli_fleet.py +++ b/test/unit/deadline_client/cli/test_cli_fleet.py @@ -3,6 +3,7 @@ """ Tests for the CLI fleet commands. """ + from unittest.mock import patch from copy import deepcopy import os diff --git a/test/unit/deadline_client/cli/test_cli_handle_web_url.py b/test/unit/deadline_client/cli/test_cli_handle_web_url.py index 2a221008..f6d0e58d 100644 --- a/test/unit/deadline_client/cli/test_cli_handle_web_url.py +++ b/test/unit/deadline_client/cli/test_cli_handle_web_url.py @@ -3,6 +3,7 @@ """ Tests for the CLI handle-web-url command. """ + import os import sys from typing import Dict, List diff --git a/test/unit/deadline_client/cli/test_cli_job.py b/test/unit/deadline_client/cli/test_cli_job.py index 57305d0b..9d5323d6 100644 --- a/test/unit/deadline_client/cli/test_cli_job.py +++ b/test/unit/deadline_client/cli/test_cli_job.py @@ -3,6 +3,7 @@ """ Tests for the CLI job commands. """ + import datetime import json import os @@ -351,9 +352,7 @@ def test_cli_job_download_output_stdout_with_only_required_input( job_group, "OutputDownloader" ) as MockOutputDownloader, patch.object( job_group, "_get_conflicting_filenames", return_value=[] - ), patch.object( - job_group, "round", return_value=0 - ), patch.object( + ), patch.object(job_group, "round", return_value=0), patch.object( api, "get_queue_user_boto3_session" ): mock_download = MagicMock() @@ -459,9 +458,7 @@ def test_cli_job_download_output_stdout_with_mismatching_path_format( job_group, "OutputDownloader" ) as MockOutputDownloader, patch.object( job_group, "_get_conflicting_filenames", return_value=[] - ), patch.object( - job_group, "round", return_value=0 - ), patch.object( + ), patch.object(job_group, "round", return_value=0), patch.object( api, "get_queue_user_boto3_session" ): mock_download = MagicMock() @@ -556,9 +553,7 @@ def test_cli_job_download_output_handles_unc_path_on_windows(fresh_deadline_conf job_group, "OutputDownloader" ) as MockOutputDownloader, patch.object( job_group, "_get_conflicting_filenames", return_value=[] - ), patch.object( - job_group, "round", return_value=0 - ), patch.object( + ), patch.object(job_group, "round", return_value=0), patch.object( api, "get_queue_user_boto3_session" ): mock_download = MagicMock() @@ -648,9 +643,7 @@ def test_cli_job_download_no_output_stdout(fresh_deadline_config, tmp_path: Path job_group, "OutputDownloader" ) as MockOutputDownloader, patch.object( job_group, "_get_conflicting_filenames", return_value=[] - ), patch.object( - job_group, "round", return_value=0 - ), patch.object( + ), patch.object(job_group, "round", return_value=0), patch.object( api, "get_queue_user_boto3_session" ): mock_download = MagicMock() @@ -713,9 +706,7 @@ def test_cli_job_download_output_stdout_with_json_format( job_group, "OutputDownloader" ) as MockOutputDownloader, patch.object(job_group, "round", return_value=0), patch.object( job_group, "_get_conflicting_filenames", return_value=[] - ), patch.object( - job_group, "_assert_valid_path", return_value=None - ), patch.object( + ), patch.object(job_group, "_assert_valid_path", return_value=None), patch.object( api, "get_queue_user_boto3_session" ): mock_download = MagicMock() diff --git a/test/unit/deadline_client/cli/test_cli_manifest.py b/test/unit/deadline_client/cli/test_cli_manifest.py index e625a5f3..d9b8d41b 100644 --- a/test/unit/deadline_client/cli/test_cli_manifest.py +++ b/test/unit/deadline_client/cli/test_cli_manifest.py @@ -171,7 +171,6 @@ def _mock_read_local_manifest(manifest): @pytest.mark.skip("Random Failure with no credentials on Github") class TestSnapshot: - def test_snapshot_root_directory_only( self, tmp_path, mock_prepare_paths_for_upload, mock_hash_attachments, mock_upload_group ): diff --git a/test/unit/deadline_client/cli/test_cli_queue.py b/test/unit/deadline_client/cli/test_cli_queue.py index 821e49e8..1d241103 100644 --- a/test/unit/deadline_client/cli/test_cli_queue.py +++ b/test/unit/deadline_client/cli/test_cli_queue.py @@ -3,6 +3,7 @@ """ Tests for the CLI queue commands. """ + from unittest.mock import patch import boto3 # type: ignore[import] diff --git a/test/unit/deadline_client/job_bundle/test_adaptors.py b/test/unit/deadline_client/job_bundle/test_adaptors.py index b0df847d..44b8b230 100644 --- a/test/unit/deadline_client/job_bundle/test_adaptors.py +++ b/test/unit/deadline_client/job_bundle/test_adaptors.py @@ -64,7 +64,7 @@ def _get_inclusive_range(start, end, step): "frame_string,result", [ ( - f"{start}{('-'+str(end)) if end is not None else ''}{(':'+str(step)) if step is not None else ''}", + f"{start}{('-' + str(end)) if end is not None else ''}{(':' + str(step)) if step is not None else ''}", _get_inclusive_range(start, end, step), ) for start in (-20, 0, 20) diff --git a/test/unit/deadline_client/job_bundle/test_job_parameters.py b/test/unit/deadline_client/job_bundle/test_job_parameters.py index 277bc016..0e960c80 100644 --- a/test/unit/deadline_client/job_bundle/test_job_parameters.py +++ b/test/unit/deadline_client/job_bundle/test_job_parameters.py @@ -4,6 +4,7 @@ Tests the deadline.client.job_bundle.parameters functions for working with job bundle parameters """ + from __future__ import annotations import pytest diff --git a/test/unit/deadline_client/job_bundle/test_job_submission.py b/test/unit/deadline_client/job_bundle/test_job_submission.py index 2293c0d1..0579537e 100644 --- a/test/unit/deadline_client/job_bundle/test_job_submission.py +++ b/test/unit/deadline_client/job_bundle/test_job_submission.py @@ -4,6 +4,7 @@ Tests the deadline.client.job_bundle.submission functions for building up the arguments to call CreateJob with. """ + from __future__ import annotations from typing import Any, Dict diff --git a/test/unit/deadline_client/job_bundle/test_validate_user_interface_spec.py b/test/unit/deadline_client/job_bundle/test_validate_user_interface_spec.py index ef7f7fce..45fa8a39 100644 --- a/test/unit/deadline_client/job_bundle/test_validate_user_interface_spec.py +++ b/test/unit/deadline_client/job_bundle/test_validate_user_interface_spec.py @@ -2,7 +2,6 @@ """Test cases for deadline.client.job_bundle.parameters.validate_user_interface_spec""" - from __future__ import annotations import re from typing import Any, Dict, cast diff --git a/test/unit/deadline_client/testing_utilities.py b/test/unit/deadline_client/testing_utilities.py index 395a825d..147920ad 100644 --- a/test/unit/deadline_client/testing_utilities.py +++ b/test/unit/deadline_client/testing_utilities.py @@ -41,7 +41,7 @@ def _format_args_check(args: Tuple[str], args_index: int) -> str: result = ["set MATCHED=YES\n"] for i, arg in enumerate(args, start=1): result.append(f'if not "%{i}" == "{_batfile_quote(arg)}" set MATCHED=NO\n') - result.append(f'if not "%{len(args)+1}" == "" set MATCHED=NO\n') + result.append(f'if not "%{len(args) + 1}" == "" set MATCHED=NO\n') result.append(f"if %MATCHED% == NO goto no_match_{args_index}\n") return "".join(result) diff --git a/test/unit/deadline_client/ui/test_host_requirements_dataclass_serialize.py b/test/unit/deadline_client/ui/test_host_requirements_dataclass_serialize.py index 604a5f02..fc698357 100644 --- a/test/unit/deadline_client/ui/test_host_requirements_dataclass_serialize.py +++ b/test/unit/deadline_client/ui/test_host_requirements_dataclass_serialize.py @@ -3,6 +3,7 @@ """ tests the deadline.client.ui.dataclasses functions relating to serializing. """ + import pytest from deadline.client.ui.dataclasses import ( diff --git a/test/unit/deadline_client/ui/widgets/test_host_requirements_tab.py b/test/unit/deadline_client/ui/widgets/test_host_requirements_tab.py index 57ea8744..79d37f25 100644 --- a/test/unit/deadline_client/ui/widgets/test_host_requirements_tab.py +++ b/test/unit/deadline_client/ui/widgets/test_host_requirements_tab.py @@ -114,10 +114,10 @@ def test_name_in_custom_amount_widget_should_not_allow_reserved_first_identifier with pytest.raises(NonValidInputError) as e: widget.get_requirement() - assert str( - e.value - ) == "Please make sure that the first identifier in your name is not a reserved identifier. " + str( - RESERVED_FIRST_IDENTIFIERS + assert ( + str(e.value) + == "Please make sure that the first identifier in your name is not a reserved identifier. " + + str(RESERVED_FIRST_IDENTIFIERS) ) @@ -227,8 +227,8 @@ def test_name_in_custom_attribute_widget_should_not_allow_reserved_first_identif with pytest.raises(NonValidInputError) as e: widget.get_requirement() - assert str( - e.value - ) == "Please make sure that the first identifier in your name is not a reserved identifier. " + str( - RESERVED_FIRST_IDENTIFIERS + assert ( + str(e.value) + == "Please make sure that the first identifier in your name is not a reserved identifier. " + + str(RESERVED_FIRST_IDENTIFIERS) ) diff --git a/test/unit/deadline_job_attachments/api/test_attachment.py b/test/unit/deadline_job_attachments/api/test_attachment.py index ff92d895..b48d930c 100644 --- a/test/unit/deadline_job_attachments/api/test_attachment.py +++ b/test/unit/deadline_job_attachments/api/test_attachment.py @@ -106,7 +106,6 @@ def session_mock(): class TestAttachmentDownload: - @pytest.fixture def mock_download_files_from_manifests(self): with patch( @@ -254,7 +253,6 @@ def test_download_invalid_input_s3_root_uri(self, session_mock): class TestAttachmentUpload: - @pytest.fixture def mock_upload_assets(self): with patch.object( diff --git a/test/unit/deadline_job_attachments/api/test_manifest_diff.py b/test/unit/deadline_job_attachments/api/test_manifest_diff.py index ca0e6257..9104c1a0 100644 --- a/test/unit/deadline_job_attachments/api/test_manifest_diff.py +++ b/test/unit/deadline_job_attachments/api/test_manifest_diff.py @@ -14,7 +14,6 @@ class TestDiffAPI: - @pytest.fixture def temp_dir(self): with tempfile.TemporaryDirectory() as tmpdir_path: diff --git a/test/unit/deadline_job_attachments/api/test_manifest_download.py b/test/unit/deadline_job_attachments/api/test_manifest_download.py index cbfd88f5..a42e2cfb 100644 --- a/test/unit/deadline_job_attachments/api/test_manifest_download.py +++ b/test/unit/deadline_job_attachments/api/test_manifest_download.py @@ -10,7 +10,6 @@ class TestManifestDownload: - @pytest.fixture def temp_dir(self): with tempfile.TemporaryDirectory() as tmpdir_path: @@ -40,7 +39,6 @@ def test_download_job( step_manifests: List, temp_dir: str, ) -> None: - # This is heavily mocked, so return nothing. Integration tests tests full manifest merging. mock_get_manifest_from_s3.return_value = None mock_get_output_manifest.return_value = {} diff --git a/test/unit/deadline_job_attachments/api/test_manifest_merge.py b/test/unit/deadline_job_attachments/api/test_manifest_merge.py index 2489707a..a014d30b 100644 --- a/test/unit/deadline_job_attachments/api/test_manifest_merge.py +++ b/test/unit/deadline_job_attachments/api/test_manifest_merge.py @@ -10,7 +10,6 @@ class TestMergeAPI: - def test_merge_same_file(self, temp_dir, test_manifest_one): """ Merge with one manifest file diff --git a/test/unit/deadline_job_attachments/api/test_manifest_upload.py b/test/unit/deadline_job_attachments/api/test_manifest_upload.py index 717e85e5..27c64b11 100644 --- a/test/unit/deadline_job_attachments/api/test_manifest_upload.py +++ b/test/unit/deadline_job_attachments/api/test_manifest_upload.py @@ -18,7 +18,6 @@ class TestManifestUpload: - @pytest.fixture def temp_dir(self): with tempfile.TemporaryDirectory() as tmpdir_path: diff --git a/test/unit/deadline_job_attachments/api/test_snapshot.py b/test/unit/deadline_job_attachments/api/test_snapshot.py index 0336a1d7..ea62a7f1 100644 --- a/test/unit/deadline_job_attachments/api/test_snapshot.py +++ b/test/unit/deadline_job_attachments/api/test_snapshot.py @@ -13,7 +13,6 @@ class TestSnapshotAPI: - @pytest.fixture def temp_dir(self): with tempfile.TemporaryDirectory() as tmpdir_path: diff --git a/test/unit/deadline_job_attachments/asset_manifests/test_decode.py b/test/unit/deadline_job_attachments/asset_manifests/test_decode.py index 4b8fe16a..f220c0a2 100644 --- a/test/unit/deadline_job_attachments/asset_manifests/test_decode.py +++ b/test/unit/deadline_job_attachments/asset_manifests/test_decode.py @@ -1,6 +1,7 @@ # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -""" Tests for the asset_manifests.decode module """ +"""Tests for the asset_manifests.decode module""" + from __future__ import annotations from enum import Enum diff --git a/test/unit/deadline_job_attachments/asset_manifests/test_manifest_model.py b/test/unit/deadline_job_attachments/asset_manifests/test_manifest_model.py index 9c4d4159..e4e38f00 100644 --- a/test/unit/deadline_job_attachments/asset_manifests/test_manifest_model.py +++ b/test/unit/deadline_job_attachments/asset_manifests/test_manifest_model.py @@ -1,6 +1,6 @@ # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -""" Tests for the asset manifest model """ +"""Tests for the asset manifest model""" import pytest diff --git a/test/unit/deadline_job_attachments/asset_manifests/v2023_03_03/test_asset_manifest.py b/test/unit/deadline_job_attachments/asset_manifests/v2023_03_03/test_asset_manifest.py index a2d5e7cd..d5c2d5ef 100644 --- a/test/unit/deadline_job_attachments/asset_manifests/v2023_03_03/test_asset_manifest.py +++ b/test/unit/deadline_job_attachments/asset_manifests/v2023_03_03/test_asset_manifest.py @@ -1,6 +1,7 @@ # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -""" Tests for the v2023-03-03 version of the manifest file. """ +"""Tests for the v2023-03-03 version of the manifest file.""" + import json from deadline.job_attachments.asset_manifests.v2023_03_03.asset_manifest import ( diff --git a/test/unit/deadline_job_attachments/aws/test_aws_clients.py b/test/unit/deadline_job_attachments/aws/test_aws_clients.py index 479b86d8..27fcc81b 100644 --- a/test/unit/deadline_job_attachments/aws/test_aws_clients.py +++ b/test/unit/deadline_job_attachments/aws/test_aws_clients.py @@ -1,6 +1,7 @@ # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. """Tests for aws clients""" + from unittest.mock import Mock, patch from deadline.job_attachments._aws.aws_clients import ( get_deadline_client, diff --git a/test/unit/deadline_job_attachments/aws/test_deadline.py b/test/unit/deadline_job_attachments/aws/test_deadline.py index 82d1d75e..9c58d3d2 100644 --- a/test/unit/deadline_job_attachments/aws/test_deadline.py +++ b/test/unit/deadline_job_attachments/aws/test_deadline.py @@ -1,6 +1,7 @@ # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. """Tests for Deadline AWS calls.""" + import pytest from unittest.mock import MagicMock, patch from botocore.exceptions import ClientError diff --git a/test/unit/deadline_job_attachments/caches/test_caches.py b/test/unit/deadline_job_attachments/caches/test_caches.py index f7fdfb47..c0af5bcc 100644 --- a/test/unit/deadline_job_attachments/caches/test_caches.py +++ b/test/unit/deadline_job_attachments/caches/test_caches.py @@ -51,9 +51,9 @@ def test_enter_bad_cache_path_throws_error(self, tmpdir): cdb = CacheDB("name", "table", "query", tmpdir) cdb.cache_dir = "/some/bad/path" with cdb: - assert ( - False - ), "Context manager should throw a JobAttachmentsError, this assert should not be reached" + assert False, ( + "Context manager should throw a JobAttachmentsError, this assert should not be reached" + ) assert isinstance(err.value.__cause__, OperationalError) @pytest.mark.parametrize( diff --git a/test/unit/deadline_job_attachments/conftest.py b/test/unit/deadline_job_attachments/conftest.py index 44ec05b2..aba2433a 100644 --- a/test/unit/deadline_job_attachments/conftest.py +++ b/test/unit/deadline_job_attachments/conftest.py @@ -3,6 +3,7 @@ """ Common fixtures for deadline tests. """ + from __future__ import annotations import dataclasses import json diff --git a/test/unit/deadline_job_attachments/test_asset_sync.py b/test/unit/deadline_job_attachments/test_asset_sync.py index 8811e941..6f1e350f 100644 --- a/test/unit/deadline_job_attachments/test_asset_sync.py +++ b/test/unit/deadline_job_attachments/test_asset_sync.py @@ -229,9 +229,7 @@ def test_sync_inputs_successful( f"{deadline.__package__}.job_attachments.asset_sync.mount_vfs_from_manifests" ), patch( f"{deadline.__package__}.job_attachments.asset_sync.VFSProcessManager.find_vfs" - ), patch.object( - Path, "stat", MagicMock(st_mtime_ns=1234512345123451) - ): + ), patch.object(Path, "stat", MagicMock(st_mtime_ns=1234512345123451)): mock_on_downloading_files = MagicMock(return_value=True) (_, result_pathmap_rules) = self.default_asset_sync.sync_inputs( @@ -362,9 +360,7 @@ def test_sync_inputs_with_step_dependencies( ), patch( f"{deadline.__package__}.job_attachments.asset_sync.get_output_manifests_by_asset_root", side_effect=[{step_output_root: {}}], - ), patch.object( - Path, "stat", MagicMock(st_mtime_ns=1234512345123451) - ): + ), patch.object(Path, "stat", MagicMock(st_mtime_ns=1234512345123451)): mock_on_downloading_files = MagicMock(return_value=True) (_, result_pathmap_rules) = self.default_asset_sync.sync_inputs( @@ -448,13 +444,9 @@ def test_sync_inputs_with_step_dependencies_same_root_vfs_on_posix( ) as disk_capacity_mock, patch( f"{deadline.__package__}.job_attachments.download._write_manifest_to_temp_file", return_value="tmp_manifest", - ), patch( - "sys.platform", "linux" - ), patch( + ), patch("sys.platform", "linux"), patch( f"{deadline.__package__}.job_attachments.asset_sync.mount_vfs_from_manifests" - ), patch( - f"{deadline.__package__}.job_attachments.asset_sync.VFSProcessManager.find_vfs" - ): + ), patch(f"{deadline.__package__}.job_attachments.asset_sync.VFSProcessManager.find_vfs"): mock_on_downloading_files = MagicMock(return_value=True) (_, result_pathmap_rules) = self.default_asset_sync.sync_inputs( @@ -535,9 +527,7 @@ def test_sync_inputs_no_space_left( ), patch( f"{deadline.__package__}.job_attachments.asset_sync._get_unique_dest_dir_name", side_effect=[dest_dir], - ), patch.object( - Path, "stat", MagicMock(st_mtime_ns=1234512345123451) - ): + ), patch.object(Path, "stat", MagicMock(st_mtime_ns=1234512345123451)): mock_on_downloading_files = MagicMock(return_value=True) with pytest.raises(AssetSyncError) as ase: @@ -889,9 +879,7 @@ def test_sync_inputs_with_storage_profiles_path_mapping_rules( ) as mock_download_files_from_manifests, patch( f"{deadline.__package__}.job_attachments.asset_sync._get_unique_dest_dir_name", side_effect=[dest_dir], - ), patch.object( - Path, "stat", MagicMock(st_mtime_ns=1234512345123451) - ): + ), patch.object(Path, "stat", MagicMock(st_mtime_ns=1234512345123451)): mock_on_downloading_files = MagicMock(return_value=True) (summary_statistics, result_pathmap_rules) = self.default_asset_sync.sync_inputs( @@ -974,9 +962,7 @@ def test_sync_inputs_successful_using_vfs_fallback( side_effect=VFSExecutableMissingError, ), patch( f"{deadline.__package__}.job_attachments.asset_sync.mount_vfs_from_manifests" - ) as mock_mount_vfs, patch( - "sys.platform", "linux" - ), patch.object( + ) as mock_mount_vfs, patch("sys.platform", "linux"), patch.object( Path, "stat", MagicMock(st_mtime_ns=1234512345123451) ): mock_on_downloading_files = MagicMock(return_value=True) @@ -1153,9 +1139,7 @@ def test_attachment_sync_inputs_successful( f"{deadline.__package__}.job_attachments.asset_sync.mount_vfs_from_manifests" ), patch( f"{deadline.__package__}.job_attachments.asset_sync.VFSProcessManager.find_vfs" - ), patch.object( - Path, "stat", MagicMock(st_mtime_ns=1234512345123451) - ): + ), patch.object(Path, "stat", MagicMock(st_mtime_ns=1234512345123451)): mock_on_downloading_files = MagicMock(return_value=True) (_, result_pathmap_rules) = self.default_asset_sync.attachment_sync_inputs( @@ -1281,9 +1265,7 @@ def test_attachment_sync_inputs_with_step_dependencies( ), patch( f"{deadline.__package__}.job_attachments.asset_sync.get_output_manifests_by_asset_root", side_effect=[{step_output_root: {}}], - ), patch.object( - Path, "stat", MagicMock(st_mtime_ns=1234512345123451) - ): + ), patch.object(Path, "stat", MagicMock(st_mtime_ns=1234512345123451)): mock_on_downloading_files = MagicMock(return_value=True) (_, result_pathmap_rules) = self.default_asset_sync.attachment_sync_inputs( @@ -1364,13 +1346,9 @@ def test_attachment_sync_inputs_with_step_dependencies_same_root_vfs_on_posix( ) as disk_capacity_mock, patch( f"{deadline.__package__}.job_attachments.download._write_manifest_to_temp_file", return_value="tmp_manifest", - ), patch( - "sys.platform", "linux" - ), patch( + ), patch("sys.platform", "linux"), patch( f"{deadline.__package__}.job_attachments.asset_sync.mount_vfs_from_manifests" - ), patch( - f"{deadline.__package__}.job_attachments.asset_sync.VFSProcessManager.find_vfs" - ): + ), patch(f"{deadline.__package__}.job_attachments.asset_sync.VFSProcessManager.find_vfs"): mock_on_downloading_files = MagicMock(return_value=True) (_, result_pathmap_rules) = self.default_asset_sync.attachment_sync_inputs( @@ -1448,9 +1426,7 @@ def test_attachment_sync_inputs_no_space_left( ), patch( f"{deadline.__package__}.job_attachments.asset_sync._get_unique_dest_dir_name", side_effect=[dest_dir], - ), patch.object( - Path, "stat", MagicMock(st_mtime_ns=1234512345123451) - ): + ), patch.object(Path, "stat", MagicMock(st_mtime_ns=1234512345123451)): mock_on_downloading_files = MagicMock(return_value=True) with pytest.raises(AssetSyncError) as ase: @@ -1520,7 +1496,6 @@ def test_aggregate_asset_root_manifests_and_write( f"{deadline.__package__}.job_attachments.asset_sync.S3AssetUploader._write_local_input_manifest", return_value=path_write_local_input_manifest, ) as mock__write_local_input_manifest: - merged_manifests_by_root = self.default_asset_sync._aggregate_asset_root_manifests( session_dir=tmp_path, s3_settings=default_job_attachment_s3_settings, @@ -1598,9 +1573,7 @@ def test_attachment_sync_inputs_with_storage_profiles_path_mapping_rules( ) as mock_download_files_from_manifests, patch( f"{deadline.__package__}.job_attachments.asset_sync._get_unique_dest_dir_name", side_effect=[dest_dir], - ), patch.object( - Path, "stat", MagicMock(st_mtime_ns=1234512345123451) - ): + ), patch.object(Path, "stat", MagicMock(st_mtime_ns=1234512345123451)): mock_on_downloading_files = MagicMock(return_value=True) (summary_statistics, result_pathmap_rules) = ( @@ -1685,9 +1658,7 @@ def test_attachment_sync_inputs_successful_using_vfs_fallback( side_effect=VFSExecutableMissingError, ), patch( f"{deadline.__package__}.job_attachments.asset_sync.mount_vfs_from_manifests" - ) as mock_mount_vfs, patch( - "sys.platform", "linux" - ), patch.object( + ) as mock_mount_vfs, patch("sys.platform", "linux"), patch.object( Path, "stat", MagicMock(st_mtime_ns=1234512345123451) ): mock_on_downloading_files = MagicMock(return_value=True) diff --git a/test/unit/deadline_job_attachments/test_download.py b/test/unit/deadline_job_attachments/test_download.py index 7cb72878..b45c886d 100644 --- a/test/unit/deadline_job_attachments/test_download.py +++ b/test/unit/deadline_job_attachments/test_download.py @@ -1,6 +1,7 @@ # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. """Tests for downloading files from the Job Attachment CAS.""" + from __future__ import annotations import os @@ -1912,9 +1913,7 @@ def test_download_file_error_message_on_timeout(self): ), patch( f"{deadline.__package__}.job_attachments.download.get_s3_transfer_manager", return_value=mock_transfer_manager, - ), patch( - f"{deadline.__package__}.job_attachments.download.Path.mkdir" - ): + ), patch(f"{deadline.__package__}.job_attachments.download.Path.mkdir"): with pytest.raises(AssetSyncError) as exc: download_file( file_path, @@ -1959,9 +1958,7 @@ def test_windows_long_path_exception_PosixOS(self): ), patch( f"{deadline.__package__}.job_attachments.download.get_s3_transfer_manager", return_value=mock_transfer_manager, - ), patch( - f"{deadline.__package__}.job_attachments.download.Path.mkdir" - ): + ), patch(f"{deadline.__package__}.job_attachments.download.Path.mkdir"): with pytest.raises(AssetSyncError) as exc: download_file( file_path, @@ -2001,9 +1998,7 @@ def test_windows_long_path_exception_WindowsOS(self): ), patch( f"{deadline.__package__}.job_attachments.download.get_s3_transfer_manager", return_value=mock_transfer_manager, - ), patch( - f"{deadline.__package__}.job_attachments.download.Path.mkdir" - ): + ), patch(f"{deadline.__package__}.job_attachments.download.Path.mkdir"): with pytest.raises(AssetSyncError) as exc: download_file( file_path, @@ -2046,9 +2041,7 @@ def test_windows_long_path_UNC_notation_WindowsOS(self): ), patch( f"{deadline.__package__}.job_attachments.download._is_windows_long_path_registry_enabled", return_value=False, - ), patch( - f"{deadline.__package__}.job_attachments.download.Path.mkdir" - ): + ), patch(f"{deadline.__package__}.job_attachments.download.Path.mkdir"): with pytest.raises(AssetSyncError) as exc: download_file( file_path, @@ -2091,9 +2084,7 @@ def test_windows_long_path_UNC_notation_and_registry_WindowsOS(self): ), patch( f"{deadline.__package__}.job_attachments.download._is_windows_long_path_registry_enabled", return_value=True, - ), patch( - f"{deadline.__package__}.job_attachments.download.Path.mkdir" - ): + ), patch(f"{deadline.__package__}.job_attachments.download.Path.mkdir"): with pytest.raises(AssetSyncError) as exc: download_file( file_path, diff --git a/test/unit/deadline_job_attachments/test_upload.py b/test/unit/deadline_job_attachments/test_upload.py index 164f261a..f0eab26b 100644 --- a/test/unit/deadline_job_attachments/test_upload.py +++ b/test/unit/deadline_job_attachments/test_upload.py @@ -279,9 +279,7 @@ def test_asset_management( skipped_bytes=0, ) - s3 = boto3.Session(region_name="us-west-2").resource( - "s3" - ) # pylint: disable=invalid-name + s3 = boto3.Session(region_name="us-west-2").resource("s3") # pylint: disable=invalid-name bucket = s3.Bucket(self.job_attachment_s3_settings.s3BucketName) assert_expected_files_on_s3( @@ -450,9 +448,7 @@ def test_asset_management_windows_multi_root( skipped_bytes=0, ) - s3 = boto3.Session(region_name="us-west-2").resource( - "s3" - ) # pylint: disable=invalid-name + s3 = boto3.Session(region_name="us-west-2").resource("s3") # pylint: disable=invalid-name bucket = s3.Bucket(self.job_attachment_s3_settings.s3BucketName) assert_expected_files_on_s3( @@ -613,9 +609,7 @@ def test_asset_management_many_inputs( skipped_bytes=0, ) - s3 = boto3.Session(region_name="us-west-2").resource( - "s3" - ) # pylint: disable=invalid-name + s3 = boto3.Session(region_name="us-west-2").resource("s3") # pylint: disable=invalid-name bucket = s3.Bucket(self.job_attachment_s3_settings.s3BucketName) expected_files = set( @@ -792,9 +786,7 @@ def mock_hash_file(file_path: str, hash_alg: HashAlgorithm): f"{deadline.__package__}.job_attachments.models._generate_random_guid", return_value="0000", ): - s3 = boto3.Session(region_name="us-west-2").resource( - "s3" - ) # pylint: disable=invalid-name + s3 = boto3.Session(region_name="us-west-2").resource("s3") # pylint: disable=invalid-name bucket = s3.Bucket(self.job_attachment_s3_settings.s3BucketName) caplog.set_level(DEBUG) @@ -931,9 +923,7 @@ def test_asset_management_no_outputs_large_number_of_inputs_already_uploaded( f"{deadline.__package__}.job_attachments.models._generate_random_guid", return_value="0000", ): - s3 = boto3.Session(region_name="us-west-2").resource( - "s3" - ) # pylint: disable=invalid-name + s3 = boto3.Session(region_name="us-west-2").resource("s3") # pylint: disable=invalid-name bucket = s3.Bucket(self.job_attachment_s3_settings.s3BucketName) caplog.set_level(DEBUG) @@ -1669,9 +1659,7 @@ def test_asset_management_misconfigured_inputs(self, farm_id, queue_id, tmpdir): ), patch( f"{deadline.__package__}.job_attachments.upload.hash_data", side_effect=["c", "manifesthash"], - ), patch( - f"{deadline.__package__}.job_attachments.upload.hash_file", side_effect=["a"] - ): + ), patch(f"{deadline.__package__}.job_attachments.upload.hash_file", side_effect=["a"]): asset_manager = S3AssetManager( farm_id=farm_id, queue_id=queue_id, @@ -1707,9 +1695,7 @@ def test_asset_management_input_not_exists(self, farm_id, queue_id, tmpdir, capl ), patch( f"{deadline.__package__}.job_attachments.upload.hash_data", side_effect=["c", "manifesthash"], - ), patch( - f"{deadline.__package__}.job_attachments.upload.hash_file", side_effect=["a"] - ): + ), patch(f"{deadline.__package__}.job_attachments.upload.hash_file", side_effect=["a"]): caplog.set_level(INFO) mock_on_preparing_to_submit = MagicMock(return_value=True) @@ -1790,9 +1776,7 @@ def test_asset_management_input_not_exists_require_fails(self, farm_id, queue_id ), patch( f"{deadline.__package__}.job_attachments.upload.hash_data", side_effect=["c", "manifesthash"], - ), patch( - f"{deadline.__package__}.job_attachments.upload.hash_file", side_effect=["a"] - ): + ), patch(f"{deadline.__package__}.job_attachments.upload.hash_file", side_effect=["a"]): asset_manager = S3AssetManager( farm_id=farm_id, queue_id=queue_id, @@ -1947,9 +1931,7 @@ def test_manage_assets_with_symlinks( skipped_bytes=0, ) - s3 = boto3.Session(region_name="us-west-2").resource( - "s3" - ) # pylint: disable=invalid-name + s3 = boto3.Session(region_name="us-west-2").resource("s3") # pylint: disable=invalid-name bucket = s3.Bucket(self.job_attachment_s3_settings.s3BucketName) assert_expected_files_on_s3( @@ -2632,9 +2614,7 @@ def test_upload_object_to_cas_adds_cache_entry( assert file_size == 5 s3_cache.put_entry.assert_called_once_with(expected_new_entry) - s3 = boto3.Session(region_name="us-west-2").resource( - "s3" - ) # pylint: disable=invalid-name + s3 = boto3.Session(region_name="us-west-2").resource("s3") # pylint: disable=invalid-name bucket = s3.Bucket(self.job_attachment_s3_settings.s3BucketName) assert_expected_files_on_s3( diff --git a/test/unit/deadline_job_attachments/test_vfs.py b/test/unit/deadline_job_attachments/test_vfs.py index 0a8ecb0d..ddb0c581 100644 --- a/test/unit/deadline_job_attachments/test_vfs.py +++ b/test/unit/deadline_job_attachments/test_vfs.py @@ -2,7 +2,6 @@ """Tests for the Asset Synching class for task-level attachments.""" - import os import stat import sys @@ -540,9 +539,7 @@ def test_process_output_captured( ), patch( f"{deadline.__package__}.job_attachments.vfs.os.path.exists", return_value=True, - ), patch( - f"{deadline.__package__}.job_attachments.vfs.log" - ) as mock_logger, patch( + ), patch(f"{deadline.__package__}.job_attachments.vfs.log") as mock_logger, patch( f"{deadline.__package__}.job_attachments.vfs.VFSProcessManager.get_launch_environ", return_value=os.environ, ): @@ -738,9 +735,7 @@ def test_manifest_group_set( f"{deadline.__package__}.job_attachments.vfs.shutil.chown", ) as mock_chown, patch( f"{deadline.__package__}.job_attachments.vfs.os.chmod", - ) as mock_chmod, patch( - f"{deadline.__package__}.job_attachments.vfs.subprocess.run" - ), patch( + ) as mock_chmod, patch(f"{deadline.__package__}.job_attachments.vfs.subprocess.run"), patch( f"{deadline.__package__}.job_attachments.vfs.VFSProcessManager.get_launch_environ", return_value=os.environ, ), patch(