Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions packages/examples/cvat/exchange-oracle/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 . .

Expand Down
16 changes: 8 additions & 8 deletions packages/examples/cvat/exchange-oracle/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Expand All @@ -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}
```

Expand All @@ -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
```
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
CMD ["pytest"]
1 change: 1 addition & 0 deletions packages/examples/cvat/exchange-oracle/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions packages/examples/cvat/exchange-oracle/pytest.ini
Original file line number Diff line number Diff line change
@@ -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_*
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 8 additions & 4 deletions packages/examples/cvat/recording-oracle/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 . .

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Expand All @@ -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}
```

Expand All @@ -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
```
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
CMD ["pytest"]
1 change: 1 addition & 0 deletions packages/examples/cvat/recording-oracle/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions packages/examples/cvat/recording-oracle/pytest.ini
Original file line number Diff line number Diff line change
@@ -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_*
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Loading