diff --git a/packages/examples/cvat/exchange-oracle/Dockerfile b/packages/examples/cvat/exchange-oracle/Dockerfile index 86c54f1441..69e547480d 100644 --- a/packages/examples/cvat/exchange-oracle/Dockerfile +++ b/packages/examples/cvat/exchange-oracle/Dockerfile @@ -4,13 +4,17 @@ WORKDIR /app RUN apt-get update -y && \ apt-get install -y jq ffmpeg libsm6 libxext6 && \ - pip install --no-cache poetry + rm -rf /var/lib/apt/lists/* + +RUN pip install --no-cache poetry COPY pyproject.toml poetry.lock ./ -RUN poetry config virtualenvs.create false \ - && poetry install --no-interaction --no-ansi --no-root \ - && poetry cache clear pypi --all +RUN --mount=type=cache,target=/root/.cache \ + poetry config virtualenvs.create false && \ + poetry install --no-interaction --no-ansi --no-root + +RUN python -m pip uninstall -y poetry pip COPY . . diff --git a/packages/examples/cvat/exchange-oracle/README.md b/packages/examples/cvat/exchange-oracle/README.md index 7d70eeac82..d6d91ce62b 100644 --- a/packages/examples/cvat/exchange-oracle/README.md +++ b/packages/examples/cvat/exchange-oracle/README.md @@ -18,14 +18,14 @@ For deployment it is required to have PostgreSQL(v14.4) ### Run the oracle locally: -``` +```sh docker compose -f docker-compose.dev.yml up -d ./bin/start_dev.sh ``` or -``` +```sh docker compose -f docker-compose.dev.yml up -d ./bin/start_debug.sh ``` @@ -48,17 +48,17 @@ Example: [Alembic env file](https://github.com/humanprotocol/human-protocol/blob Adding new migration: -``` +```sh alembic revision --autogenerate -m "your-migration-name" ``` Upgrade: -``` +```sh alembic upgrade head ``` Downgrade: -``` +```sh alembic downgrade -{number of migrations} ``` @@ -72,7 +72,7 @@ Available at `/docs` route ### Tests To run tests -``` -docker compose -f docker-compose.test.yml up --build test --attach test --exit-code-from test && \ - docker compose -f docker-compose.test.yml down +```sh +docker compose -p "test" -f docker-compose.test.yml up --build test --attach test --exit-code-from test; \ + docker compose -p "test" -f docker-compose.test.yml down ``` \ No newline at end of file diff --git a/packages/examples/cvat/exchange-oracle/dockerfiles/test.Dockerfile b/packages/examples/cvat/exchange-oracle/dockerfiles/test.Dockerfile index f2341c8d22..eaa436f5d0 100644 --- a/packages/examples/cvat/exchange-oracle/dockerfiles/test.Dockerfile +++ b/packages/examples/cvat/exchange-oracle/dockerfiles/test.Dockerfile @@ -4,16 +4,20 @@ WORKDIR /app RUN apt-get update -y && \ apt-get install -y jq ffmpeg libsm6 libxext6 && \ - pip install --no-cache poetry + rm -rf /var/lib/apt/lists/* + +RUN pip install --no-cache poetry COPY pyproject.toml poetry.lock ./ -RUN poetry config virtualenvs.create false \ - && poetry install --no-interaction --no-ansi --no-root \ - && poetry cache clear pypi --all +RUN --mount=type=cache,target=/root/.cache \ + poetry config virtualenvs.create false && \ + poetry install --no-interaction --no-ansi --no-root + +RUN python -m pip uninstall -y poetry pip COPY . . RUN rm -f ./src/.env -CMD ["pytest", "-W", "ignore::DeprecationWarning", "-v"] \ No newline at end of file +CMD ["pytest"] \ No newline at end of file diff --git a/packages/examples/cvat/exchange-oracle/pyproject.toml b/packages/examples/cvat/exchange-oracle/pyproject.toml index 5dd04c1813..2170018394 100644 --- a/packages/examples/cvat/exchange-oracle/pyproject.toml +++ b/packages/examples/cvat/exchange-oracle/pyproject.toml @@ -134,6 +134,7 @@ ignore = [ "ANN001", # | "ANN003", # | "ARG001", # | + "FBT001", # Allow bool-annotated positional args in functions "SLF001", # Allow private attrs access "PLR2004", # Allow magic values "S", # security diff --git a/packages/examples/cvat/exchange-oracle/pytest.ini b/packages/examples/cvat/exchange-oracle/pytest.ini new file mode 100644 index 0000000000..bdf7142e2b --- /dev/null +++ b/packages/examples/cvat/exchange-oracle/pytest.ini @@ -0,0 +1,10 @@ +[pytest] +addopts = --verbose +filterwarnings = + ignore::DeprecationWarning:cvat_sdk.core + ignore::DeprecationWarning:human_protocol_sdk.storage + ignore:Field name \"sort\" shadows:UserWarning:pydantic._internal._fields + +python_files = test_*.py +python_classes = *Test +python_functions = test_* \ No newline at end of file diff --git a/packages/examples/cvat/exchange-oracle/src/handlers/job_creation.py b/packages/examples/cvat/exchange-oracle/src/handlers/job_creation.py index 566d69a959..40570c0540 100644 --- a/packages/examples/cvat/exchange-oracle/src/handlers/job_creation.py +++ b/packages/examples/cvat/exchange-oracle/src/handlers/job_creation.py @@ -230,7 +230,7 @@ def _setup_gt_job_for_cvat_task( with TemporaryDirectory() as tmp_dir: export_dir = Path(tmp_dir) / "export" - gt_dataset.export(save_dir=str(export_dir), save_images=False, format=dm_export_format) + gt_dataset.export(save_dir=str(export_dir), save_media=False, format=dm_export_format) annotations_archive_path = Path(tmp_dir) / "annotations.zip" with annotations_archive_path.open("wb") as annotations_archive: diff --git a/packages/examples/cvat/exchange-oracle/src/handlers/job_export.py b/packages/examples/cvat/exchange-oracle/src/handlers/job_export.py index 6b93567965..a3d67c7eb6 100644 --- a/packages/examples/cvat/exchange-oracle/src/handlers/job_export.py +++ b/packages/examples/cvat/exchange-oracle/src/handlers/job_export.py @@ -130,7 +130,7 @@ def _parse_dataset(self, ann_descriptor: FileDescriptor, dataset_dir: str) -> dm return dm.Dataset.import_from(dataset_dir, self.input_format) def _export_dataset(self, dataset: dm.Dataset, output_dir: str): - dataset.export(output_dir, self.output_format, save_images=False) + dataset.export(output_dir, self.output_format, save_media=False) def _process_dataset( self, dataset: dm.Dataset, *, ann_descriptor: FileDescriptor diff --git a/packages/examples/cvat/recording-oracle/Dockerfile b/packages/examples/cvat/recording-oracle/Dockerfile index 86c54f1441..69e547480d 100644 --- a/packages/examples/cvat/recording-oracle/Dockerfile +++ b/packages/examples/cvat/recording-oracle/Dockerfile @@ -4,13 +4,17 @@ WORKDIR /app RUN apt-get update -y && \ apt-get install -y jq ffmpeg libsm6 libxext6 && \ - pip install --no-cache poetry + rm -rf /var/lib/apt/lists/* + +RUN pip install --no-cache poetry COPY pyproject.toml poetry.lock ./ -RUN poetry config virtualenvs.create false \ - && poetry install --no-interaction --no-ansi --no-root \ - && poetry cache clear pypi --all +RUN --mount=type=cache,target=/root/.cache \ + poetry config virtualenvs.create false && \ + poetry install --no-interaction --no-ansi --no-root + +RUN python -m pip uninstall -y poetry pip COPY . . diff --git a/packages/examples/cvat/recording-oracle/README.MD b/packages/examples/cvat/recording-oracle/README.md similarity index 87% rename from packages/examples/cvat/recording-oracle/README.MD rename to packages/examples/cvat/recording-oracle/README.md index 55faf0c916..6b412f5081 100644 --- a/packages/examples/cvat/recording-oracle/README.MD +++ b/packages/examples/cvat/recording-oracle/README.md @@ -18,14 +18,14 @@ For deployment it is required to have PostgreSQL(v14.4) ### Run the oracle locally: -``` +```sh docker compose -f docker-compose.dev.yml up -d ./bin/start_dev.sh ``` or -``` +```sh docker compose -f docker-compose.dev.yml up -d ./bin/start_debug.sh ``` @@ -46,17 +46,17 @@ Config file: `/src/config.py` To simplify the process and use `--autogenerate` flag, you need to import a new model to `/alembic/env.py` Adding new migration: -``` +```sh alembic revision --autogenerate -m "your-migration-name" ``` Upgrade: -``` +```sh alembic upgrade head ``` Downgrade: -``` +```sh alembic downgrade -{number of migrations} ``` @@ -69,6 +69,7 @@ Available at `/docs` route ### Tests To run tests -``` -docker compose -f docker-compose.test.yml up --build test --attach test --exit-code-from test +```sh +docker compose -p "test" -f docker-compose.test.yml up --build test --attach test --exit-code-from test; \ + docker compose -p "test" -f docker-compose.test.yml down ``` diff --git a/packages/examples/cvat/recording-oracle/dockerfiles/test.Dockerfile b/packages/examples/cvat/recording-oracle/dockerfiles/test.Dockerfile index 591d0cb769..eaa436f5d0 100644 --- a/packages/examples/cvat/recording-oracle/dockerfiles/test.Dockerfile +++ b/packages/examples/cvat/recording-oracle/dockerfiles/test.Dockerfile @@ -4,16 +4,20 @@ WORKDIR /app RUN apt-get update -y && \ apt-get install -y jq ffmpeg libsm6 libxext6 && \ - pip install --no-cache poetry + rm -rf /var/lib/apt/lists/* + +RUN pip install --no-cache poetry COPY pyproject.toml poetry.lock ./ -RUN poetry config virtualenvs.create false \ - && poetry install --no-interaction --no-ansi --no-root \ - && poetry cache clear pypi --all +RUN --mount=type=cache,target=/root/.cache \ + poetry config virtualenvs.create false && \ + poetry install --no-interaction --no-ansi --no-root + +RUN python -m pip uninstall -y poetry pip COPY . . RUN rm -f ./src/.env -CMD ["pytest", "-W", "ignore::DeprecationWarning", "-W", "ignore::RuntimeWarning", "-W", "ignore::UserWarning", "-v"] \ No newline at end of file +CMD ["pytest"] \ No newline at end of file diff --git a/packages/examples/cvat/recording-oracle/pyproject.toml b/packages/examples/cvat/recording-oracle/pyproject.toml index 194543a267..e12f60a4ce 100644 --- a/packages/examples/cvat/recording-oracle/pyproject.toml +++ b/packages/examples/cvat/recording-oracle/pyproject.toml @@ -123,6 +123,7 @@ ignore = [ "ANN001", # | "ANN003", # | "ARG001", # | + "FBT001", # Allow bool-annotated positional args in functions "SLF001", # Allow private attrs access "PLR2004", # Allow magic values "S", # security diff --git a/packages/examples/cvat/recording-oracle/pytest.ini b/packages/examples/cvat/recording-oracle/pytest.ini new file mode 100644 index 0000000000..bdf7142e2b --- /dev/null +++ b/packages/examples/cvat/recording-oracle/pytest.ini @@ -0,0 +1,10 @@ +[pytest] +addopts = --verbose +filterwarnings = + ignore::DeprecationWarning:cvat_sdk.core + ignore::DeprecationWarning:human_protocol_sdk.storage + ignore:Field name \"sort\" shadows:UserWarning:pydantic._internal._fields + +python_files = test_*.py +python_classes = *Test +python_functions = test_* \ No newline at end of file diff --git a/packages/examples/cvat/recording-oracle/tests/integration/services/test_validation_service.py b/packages/examples/cvat/recording-oracle/tests/integration/services/test_validation_service.py index 1ba1e17052..e901f89c14 100644 --- a/packages/examples/cvat/recording-oracle/tests/integration/services/test_validation_service.py +++ b/packages/examples/cvat/recording-oracle/tests/integration/services/test_validation_service.py @@ -103,7 +103,7 @@ def test_create_and_get_validation_result(self): assert vrs[0] == vr -class TestManifestChange: +class ManifestChangeTest: def test_can_handle_lowered_quality_requirements_in_manifest(self, session: Session): escrow_address = ESCROW_ADDRESS chain_id = Networks.localhost @@ -282,7 +282,7 @@ def test_can_handle_lowered_quality_requirements_in_manifest(self, session: Sess ) -class TestValidationLogic: +class ValidationLogicTest: @pytest.mark.parametrize("seed", range(25)) def test_can_change_bad_honeypots_in_jobs(self, session: Session, seed: int): escrow_address = ESCROW_ADDRESS @@ -1134,7 +1134,7 @@ def patched_get_jobs_quality_reports(task_id: int): mock_update_task_validation_layout.assert_not_called() -class TestAnnotationMerging: +class AnnotationMergingTest: def test_can_prepare_final_results_in_validated_escrow(self, session: Session): escrow_address = ESCROW_ADDRESS chain_id = Networks.localhost.value