Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

py: widen to python 3.9 #5

Merged
merged 1 commit into from
Aug 10, 2024
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
25 changes: 23 additions & 2 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@ on:
jobs:
pytest:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ '3.9', '3.10', '3.11', '3.12' ]
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '3.10'
python-version: ${{ matrix.python-version }}
- name: Install Poetry
run: |
pipx install poetry
Expand All @@ -25,3 +28,21 @@ jobs:
- name: Run tests
run: |
make test
- name: Run mypy
run: |
make mypy
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: '3.9'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install ruff
- name: Run Ruff
run: |
ruff check --config=pyproject.toml --output-format=github .
4 changes: 2 additions & 2 deletions .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
python-version: '3.9'
- name: Install Poetry
run: |
pipx install poetry
Expand Down Expand Up @@ -43,7 +43,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
python-version: '3.9'
- name: Install Poetry
run: |
pipx install poetry
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ __pycache__
*.omlmd.json
*.omlmd.yaml
*.joblib
*.gguf
tmp
efi-variable-store
*.onnx
Expand Down
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,11 @@ test:
.PHONY: test-e2e
test-e2e:
poetry run pytest --e2e -s -x -rA

.PHONY: lint
lint:
poetry run ruff check --fix

.PHONY: mypy
mypy:
poetry run mypy .
5 changes: 2 additions & 3 deletions omlmd/helpers.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from dataclasses import dataclass, field, asdict, fields
from typing import Optional, Dict, Any, List
from dataclasses import fields
from typing import Optional, List
from omlmd.model_metadata import ModelMetadata
from oras.provider import Registry
from omlmd.provider import OMLMDRegistry
import os
import urllib.request
Expand Down
4 changes: 2 additions & 2 deletions omlmd/model_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ class ModelMetadata:
def to_json(self) -> str:
return json.dumps(asdict(self), indent=4)

def to_dict(self) -> str:
def to_dict(self) -> dict[str, Any]:
as_json = self.to_json()
return json.loads(as_json)

def to_annotations_dict(self) -> str:
def to_annotations_dict(self) -> dict[str, str]:
as_dict = self.to_dict()
result = {}
# TODO: likely key in annotation require FQDN
Expand Down
4 changes: 2 additions & 2 deletions omlmd/provider.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import os
import sys

import oras.defaults
import oras.oci
Expand All @@ -26,7 +25,7 @@ def download_layers(self, package, download_dir, media_types):
paths = []

for layer in manifest.get('layers', []):
if media_types == None or len(media_types) == 0 or layer['mediaType'] in media_types:
if media_types is None or len(media_types) == 0 or layer['mediaType'] in media_types:
artifact = layer['annotations']['org.opencontainers.image.title']
outfile = oras.utils.sanitize_path(download_dir, os.path.join(download_dir, artifact))
path = self.download_blob(package, layer['digest'], outfile)
Expand Down Expand Up @@ -63,3 +62,4 @@ def get_config(self, package) -> str:
os.rmdir(os.path.join(root, dir))
os.rmdir(temp_dir)
# print("Temporary directory and its contents have been removed.")
raise RuntimeError("Unable to locate config layer")
829 changes: 783 additions & 46 deletions poetry.lock

Large diffs are not rendered by default.

19 changes: 18 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ authors = ["Matteo Mortari <[email protected]>"]
readme = "README.md"

[tool.poetry.dependencies]
python = "^3.10"
python = "^3.9"
oras = "^0.1.30"
pyyaml = "^6.0.1"
nbconvert = "^7.16.4"
Expand All @@ -19,6 +19,10 @@ jq = "^1.7.0"
scikit-learn = "^1.5.0"
ipykernel = "^6.29.4"
markdown-it-py = "^3.0.0"
model-registry = "^0.2.4a1"
ruff = "^0.5.7"
mypy = "^1.11.1"
types-pyyaml = "^6.0.12.20240808"

[tool.poetry.scripts]
omlmd = "omlmd.cli:cli"
Expand All @@ -31,3 +35,16 @@ build-backend = "poetry.core.masonry.api"
markers = [
"e2e: end-to-end testing with localhost:5001",
]

[tool.ruff]
target-version = "py39"
respect-gitignore = true

[tool.mypy]
python_version = "3.9"
strict = false
pretty = true
show_column_numbers = true
show_error_codes = true
show_error_context = true
ignore_missing_imports = true
Loading