diff --git a/extract/psdonline/src/psdonline/execute.py b/extract/psdonline/src/psdonline/execute.py index 29704f3..0829fd4 100644 --- a/extract/psdonline/src/psdonline/execute.py +++ b/extract/psdonline/src/psdonline/execute.py @@ -1,9 +1,10 @@ -import niquests -import pathlib import logging +import pathlib import sys from datetime import datetime +import niquests + logging.basicConfig( level=logging.INFO, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', @@ -23,7 +24,7 @@ FIRST_MONTH = 8 def extract_psd_file(url:str, extract_to_path: pathlib.Path, http_session: niquests.Session): logger.info(f"Requesting file {url} ...") - extracted_etags = list(map(lambda file: file.stem, OUTPUT_DIR.rglob("*.zip"))) + extracted_etags = [file.stem for file in OUTPUT_DIR.rglob("*.zip")] response = http_session.head(url) if response.status_code == 404: diff --git a/pyproject.toml b/pyproject.toml index f762089..fa896bd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -83,30 +83,12 @@ exclude = [ "notebooks", ] -# Set line length to match common Python style -line-length = 88 indent-width = 4 -# Assume Python 3.13 target-version = "py313" [tool.ruff.lint] -# Enable recommended rules plus additional useful ones -select = [ - "E", # pycodestyle errors - "W", # pycodestyle warnings - "F", # pyflakes - "I", # isort - "N", # pep8-naming - "UP", # pyupgrade - "B", # flake8-bugbear - "C4", # flake8-comprehensions - "SIM", # flake8-simplify - "PL", # pylint - "RUF", # ruff-specific rules -] -# Ignore specific rules that may be too strict ignore = [ "E501", # line too long (handled by formatter) "PLR0913", # too many arguments to function call diff --git a/src/materia/cli.py b/src/materia/cli.py index 71b7df7..87dbc06 100644 --- a/src/materia/cli.py +++ b/src/materia/cli.py @@ -1,7 +1,8 @@ """Materia CLI - Management interface for BeanFlows.coffee infrastructure.""" +from typing import Annotated + import typer -from typing_extensions import Annotated app = typer.Typer( name="materia", diff --git a/src/materia/pipelines.py b/src/materia/pipelines.py index 330bd04..318af24 100644 --- a/src/materia/pipelines.py +++ b/src/materia/pipelines.py @@ -1,10 +1,12 @@ """Pipeline execution on ephemeral workers.""" -import paramiko +import contextlib from dataclasses import dataclass -from materia.workers import create_worker, destroy_worker +import paramiko + from materia.secrets import get_secret +from materia.workers import create_worker, destroy_worker @dataclass @@ -133,7 +135,5 @@ def run_pipeline( finally: if auto_destroy: - try: + with contextlib.suppress(Exception): destroy_worker(worker_name, provider) - except Exception: - pass diff --git a/src/materia/providers/__init__.py b/src/materia/providers/__init__.py index fd1218b..5d0c267 100644 --- a/src/materia/providers/__init__.py +++ b/src/materia/providers/__init__.py @@ -16,19 +16,19 @@ class Instance: class ProviderModule(Protocol): def create_instance( - name: str, + self: str, instance_type: str, ssh_key: str, location: str | None = None, ) -> Instance: ... - def destroy_instance(instance_id: str) -> None: ... + def destroy_instance(self: str) -> None: ... - def list_instances(label: str | None = None) -> list[Instance]: ... + def list_instances(self: str | None = None) -> list[Instance]: ... - def get_instance(name: str) -> Instance | None: ... + def get_instance(self: str) -> Instance | None: ... - def wait_for_ssh(ip: str, timeout: int = 300) -> bool: ... + def wait_for_ssh(self: str, timeout: int = 300) -> bool: ... def get_provider(provider_name: str) -> ProviderModule: diff --git a/src/materia/providers/hetzner.py b/src/materia/providers/hetzner.py index 2ca4139..a8bfca2 100644 --- a/src/materia/providers/hetzner.py +++ b/src/materia/providers/hetzner.py @@ -1,7 +1,7 @@ """Hetzner Cloud provider implementation.""" -import time import socket +import time from hcloud import Client from hcloud.images import Image diff --git a/src/materia/workers.py b/src/materia/workers.py index 61acc6c..c8f8699 100644 --- a/src/materia/workers.py +++ b/src/materia/workers.py @@ -3,7 +3,6 @@ from materia.providers import Instance, get_provider from materia.secrets import get_secret - DEFAULT_PROVIDER = "hetzner" diff --git a/tests/conftest.py b/tests/conftest.py index 28b08df..99b7dba 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,8 +1,9 @@ """Pytest configuration and fixtures.""" -import pytest from unittest.mock import Mock, patch +import pytest + @pytest.fixture def mock_esc_env(tmp_path): diff --git a/tests/test_cli_e2e.py b/tests/test_cli_e2e.py index 87426c1..fb9cc0b 100644 --- a/tests/test_cli_e2e.py +++ b/tests/test_cli_e2e.py @@ -1,6 +1,7 @@ """End-to-end tests for the materia CLI.""" from typer.testing import CliRunner + from materia.cli import app runner = CliRunner()