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
4 changes: 2 additions & 2 deletions .env.integration-test
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
METADATA_DB_URL=sqlite:///:memory:
ARTIFACT_REGISTRY_URL=europe-west2-docker.pkg.dev/runsandbox-449400/
METADATA_DB_URL=postgresql+psycopg2://at_user:at_pass@localhost:5432/at_db
ARTIFACT_REGISTRY_URL=localhost:5001
LOG_LEVEL=INFO
10 changes: 10 additions & 0 deletions .github/workflows/python-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,13 @@ jobs:

- name: Run tests
run: make test

- name: Install docker-compose
run: |
sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
docker-compose --version

- name: Run integration tests
run: |
make test-integration
17 changes: 13 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,24 @@ publish: build
launch:
docker-compose up -d

.PHONY: lint
lint:
$(POETRY) run ruff check .

.PHONY: format
format:
$(POETRY) run ruff format .
$(POETRY) run ruff check .

.PHONY: test
test: format
test: lint
$(POETRY) run pytest tests/unit

.PHONY: test-integration
test-integration: format
$(POETRY) run pytest tests/integration
test-integration: lint
@bash -c '\
set -e; \
docker-compose up -d; \
trap "docker-compose down" EXIT; \
until docker exec postgres pg_isready -U at_user; do sleep 1; done; \
$(POETRY) run pytest tests/integration; \
'
4 changes: 2 additions & 2 deletions alphatrion/artifact/artifact.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@


class Artifact:
def __init__(self, runtime: Runtime):
def __init__(self, runtime: Runtime, insecure: bool = False):
self._runtime = runtime
self._url = os.environ.get(consts.ARTIFACT_REGISTRY_URL)
self._url = self._url.replace("https://", "").replace("http://", "")
self._client = oras.client.OrasClient(
hostname=self._url.strip("/"), auth_backend="token"
hostname=self._url.strip("/"), auth_backend="token", insecure=insecure
)

def push(self, experiment_name: str, files: list[str], version: str = "latest"):
Expand Down
20 changes: 13 additions & 7 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
version: "3.9"

services:
postgres:
container_name: postgres
image: postgres:16
environment:
POSTGRES_USER: at_user
POSTGRES_PASSWORD: at_pass
POSTGRES_DB: at_db
ports:
- "5432:5432"
volumes:
- pg_data:/var/lib/postgresql/data
# volumes:
# - pg_data:/var/lib/postgresql/data
deploy:
replicas: 1
restart_policy:
condition: any

volumes:
pg_data:
registry:
container_name: registry
image: registry:3
ports:
- "5001:5000"
# volumes:
# - oras-data:/data
# volumes:
# pg_data:
# oras-data:
8 changes: 7 additions & 1 deletion docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,15 @@ To run tests, use:
make test
```

To run integration tests, use:

```bash
make test-integration
```

## How to Build and Publish

> NOTE: You need to have the PyPI token set in your environment variables to publish the package.
> Note: You need to have the PyPI token set in your environment variables to publish the package.

To build the project, run:

Expand Down
80 changes: 79 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ dependencies = [
"sqlalchemy (>=2.0.43,<3.0.0)",
"python-dotenv (>=1.1.1,<2.0.0)",
"oras (>=0.2.38,<0.3.0)",
"psycopg2-binary (>=2.9.10,<3.0.0)",
]

[tool.poetry.group.dev.dependencies]
Expand Down
13 changes: 8 additions & 5 deletions tests/integration/artifact/test_artifact.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@

@pytest.fixture
def artifact():
runtime = Runtime(project_id="ckpt")
artifact = Artifact(runtime=runtime)
# We use a local registry for testing, it doesn't mean
# it will always successfully with cloud registries.
# We may need e2e tests for that.
runtime = Runtime(project_id="test_project")
artifact = Artifact(runtime=runtime, insecure=True)
yield artifact


Expand All @@ -35,6 +38,6 @@ def test_push(artifact):
tags = artifact.list_tags("test_experiment")
assert "v1" in tags

# artifact.delete_tags(experiment_name="test_experiment", versions="v1")
# tags = artifact.list_tags("test_experiment")
# assert "v1" not in tags
artifact.delete_tags(experiment_name="test_experiment", versions="v1")
tags = artifact.list_tags("test_experiment")
assert "v1" not in tags
Loading