Skip to content
Open
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
2 changes: 1 addition & 1 deletion .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,4 @@ jobs:
run: uv sync --extra dev

- name: Doctrine tests
run: PYTHONPATH=src pytest src/julee/core/doctrine/
run: uv run pytest src/julee/core/doctrine/
5 changes: 3 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,9 @@ exclude_lines = [
]

[tool.ruff]
# Ruff is used for linting only. Formatting is handled by black.
line-length = 88
target-version = "py310"
target-version = "py311"
exclude = [
".git",
".venv",
Expand Down Expand Up @@ -183,7 +184,7 @@ ignore = [
known-first-party = ["julee"]

[tool.mypy]
python_version = "3.10"
python_version = "3.11"
warn_return_any = true
warn_unused_configs = true
disallow_untyped_defs = false
Expand Down
6 changes: 3 additions & 3 deletions src/julee/api/requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
duplication while maintaining single source of truth in the domain layer.
"""

from datetime import datetime, timezone
from datetime import UTC, datetime
from typing import Any

from pydantic import BaseModel, Field, ValidationInfo, field_validator
Expand Down Expand Up @@ -90,7 +90,7 @@ def to_domain_model(self, assembly_specification_id: str) -> AssemblySpecificati
Returns:
AssemblySpecification: Complete domain object with system fields
"""
now = datetime.now(timezone.utc)
now = datetime.now(UTC)
return AssemblySpecification(
assembly_specification_id=assembly_specification_id,
name=self.name,
Expand Down Expand Up @@ -163,7 +163,7 @@ def to_domain_model(self, query_id: str) -> KnowledgeServiceQuery:
Returns:
KnowledgeServiceQuery: Complete domain object with system fields
"""
now = datetime.now(timezone.utc)
now = datetime.now(UTC)
return KnowledgeServiceQuery(
query_id=query_id,
name=self.name,
Expand Down
6 changes: 3 additions & 3 deletions src/julee/api/responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@
by existing domain models.
"""

from enum import Enum
from enum import StrEnum

from pydantic import BaseModel


class ServiceStatus(str, Enum):
class ServiceStatus(StrEnum):
"""Service status enumeration."""

UP = "up"
DOWN = "down"


class SystemStatus(str, Enum):
class SystemStatus(StrEnum):
"""Overall system status enumeration."""

HEALTHY = "healthy"
Expand Down
4 changes: 2 additions & 2 deletions src/julee/api/routers/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import asyncio
import logging
import os
from datetime import datetime, timezone
from datetime import UTC, datetime

from fastapi import APIRouter
from minio import Minio
Expand Down Expand Up @@ -133,6 +133,6 @@ async def health_check() -> HealthCheckResponse:
# Return response with string timestamp as expected by frontend
return HealthCheckResponse(
status=overall_status,
timestamp=datetime.now(timezone.utc).isoformat(),
timestamp=datetime.now(UTC).isoformat(),
services=services,
)
10 changes: 5 additions & 5 deletions src/julee/api/tests/routers/test_documents.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"""

from collections.abc import Generator
from datetime import datetime, timezone
from datetime import UTC, datetime

import pytest
from fastapi import FastAPI
Expand Down Expand Up @@ -60,8 +60,8 @@ def sample_documents() -> list[Document]:
size_bytes=1024,
content_multihash="QmTest1",
status=DocumentStatus.CAPTURED,
created_at=datetime(2024, 1, 1, 12, 0, 0, tzinfo=timezone.utc),
updated_at=datetime(2024, 1, 1, 12, 0, 0, tzinfo=timezone.utc),
created_at=datetime(2024, 1, 1, 12, 0, 0, tzinfo=UTC),
updated_at=datetime(2024, 1, 1, 12, 0, 0, tzinfo=UTC),
additional_metadata={"type": "test"},
content_bytes="test content",
),
Expand All @@ -72,8 +72,8 @@ def sample_documents() -> list[Document]:
size_bytes=2048,
content_multihash="QmTest2",
status=DocumentStatus.REGISTERED,
created_at=datetime(2024, 1, 2, 12, 0, 0, tzinfo=timezone.utc),
updated_at=datetime(2024, 1, 2, 12, 0, 0, tzinfo=timezone.utc),
created_at=datetime(2024, 1, 2, 12, 0, 0, tzinfo=UTC),
updated_at=datetime(2024, 1, 2, 12, 0, 0, tzinfo=UTC),
additional_metadata={"type": "report"},
content_bytes="pdf content",
),
Expand Down
14 changes: 7 additions & 7 deletions src/julee/api/tests/routers/test_knowledge_service_configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"""

from collections.abc import Generator
from datetime import datetime, timezone
from datetime import UTC, datetime
from unittest.mock import AsyncMock

import pytest
Expand Down Expand Up @@ -54,24 +54,24 @@ def sample_configs() -> list[KnowledgeServiceConfig]:
name="Anthropic Claude",
description="Claude 3 for general text analysis and extraction",
service_api=ServiceApi.ANTHROPIC,
created_at=datetime(2024, 1, 1, 12, 0, 0, tzinfo=timezone.utc),
updated_at=datetime(2024, 1, 1, 12, 0, 0, tzinfo=timezone.utc),
created_at=datetime(2024, 1, 1, 12, 0, 0, tzinfo=UTC),
updated_at=datetime(2024, 1, 1, 12, 0, 0, tzinfo=UTC),
),
KnowledgeServiceConfig(
knowledge_service_id="openai-gpt4",
name="OpenAI GPT-4",
description="GPT-4 for comprehensive text understanding",
service_api=ServiceApi.ANTHROPIC, # Only enum value available
created_at=datetime(2024, 1, 1, 12, 0, 0, tzinfo=timezone.utc),
updated_at=datetime(2024, 1, 1, 12, 0, 0, tzinfo=timezone.utc),
created_at=datetime(2024, 1, 1, 12, 0, 0, tzinfo=UTC),
updated_at=datetime(2024, 1, 1, 12, 0, 0, tzinfo=UTC),
),
KnowledgeServiceConfig(
knowledge_service_id="memory-service",
name="Memory Service",
description="In-memory service for testing and development",
service_api=ServiceApi.ANTHROPIC, # Only enum value available
created_at=datetime(2024, 1, 1, 12, 0, 0, tzinfo=timezone.utc),
updated_at=datetime(2024, 1, 1, 12, 0, 0, tzinfo=timezone.utc),
created_at=datetime(2024, 1, 1, 12, 0, 0, tzinfo=UTC),
updated_at=datetime(2024, 1, 1, 12, 0, 0, tzinfo=UTC),
),
]

Expand Down
4 changes: 2 additions & 2 deletions src/julee/contrib/ceap/domain/models/assembly/assembly.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
"""

from datetime import datetime
from enum import Enum
from enum import StrEnum

from pydantic import Field, field_validator

from julee.core.entities.entity import Entity


class AssemblyStatus(str, Enum):
class AssemblyStatus(StrEnum):
"""Status of an assembly process."""

PENDING = "pending"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Assembly domain objects with sensible defaults.
"""

from datetime import datetime, timezone
from datetime import UTC, datetime

from factory.base import Factory
from factory.declarations import LazyFunction
Expand Down Expand Up @@ -34,5 +34,5 @@ class Meta:
assembled_document_id = None

# Timestamps
created_at = LazyFunction(lambda: datetime.now(timezone.utc))
updated_at = LazyFunction(lambda: datetime.now(timezone.utc))
created_at = LazyFunction(lambda: datetime.now(UTC))
updated_at = LazyFunction(lambda: datetime.now(UTC))
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"""

import json
from datetime import datetime, timezone
from datetime import UTC, datetime

import pytest
from pydantic import ValidationError
Expand All @@ -31,7 +31,7 @@

pytestmark = pytest.mark.unit

_NOW = datetime(2024, 1, 1, 12, 0, 0, tzinfo=timezone.utc)
_NOW = datetime(2024, 1, 1, 12, 0, 0, tzinfo=UTC)


class TestAssemblyInstantiation:
Expand Down Expand Up @@ -196,8 +196,8 @@ def test_assembly_with_explicit_timestamps(self) -> None:

def test_assembly_custom_values(self) -> None:
"""Test Assembly with custom non-default values."""
custom_created_at = datetime(2023, 1, 1, 12, 0, 0, tzinfo=timezone.utc)
custom_updated_at = datetime(2023, 1, 2, 12, 0, 0, tzinfo=timezone.utc)
custom_created_at = datetime(2023, 1, 1, 12, 0, 0, tzinfo=UTC)
custom_updated_at = datetime(2023, 1, 2, 12, 0, 0, tzinfo=UTC)

custom_assembly = Assembly(
assembly_id="custom-id",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"""

from collections.abc import Mapping
from datetime import datetime, timezone
from enum import Enum
from datetime import UTC, datetime
from enum import StrEnum
from typing import Any

import jsonpointer # type: ignore
Expand All @@ -25,7 +25,7 @@
from julee.core.entities.entity import Entity


class AssemblySpecificationStatus(str, Enum):
class AssemblySpecificationStatus(StrEnum):
"""Status of an assembly specification configuration."""

ACTIVE = "active"
Expand Down Expand Up @@ -77,12 +77,8 @@ class AssemblySpecification(Entity):

# AssemblySpecification metadata
version: str = Field(default="0.1.0", description="Assembly definition version")
created_at: datetime | None = Field(
default_factory=lambda: datetime.now(timezone.utc)
)
updated_at: datetime | None = Field(
default_factory=lambda: datetime.now(timezone.utc)
)
created_at: datetime | None = Field(default_factory=lambda: datetime.now(UTC))
updated_at: datetime | None = Field(default_factory=lambda: datetime.now(UTC))
# May later add a detailed description, change log, additional metadata
# Timestamps

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"""

from collections.abc import Mapping
from datetime import datetime, timezone
from datetime import UTC, datetime
from typing import Any

from pydantic import Field, field_validator
Expand Down Expand Up @@ -95,12 +95,8 @@ class KnowledgeServiceQuery(Entity):
"allowing control over response format and structure.",
)

created_at: datetime | None = Field(
default_factory=lambda: datetime.now(timezone.utc)
)
updated_at: datetime | None = Field(
default_factory=lambda: datetime.now(timezone.utc)
)
created_at: datetime | None = Field(default_factory=lambda: datetime.now(UTC))
updated_at: datetime | None = Field(default_factory=lambda: datetime.now(UTC))

@field_validator("query_id")
@classmethod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
AssemblySpecification domain objects with sensible defaults.
"""

from datetime import datetime, timezone
from datetime import UTC, datetime
from typing import Any

from factory.base import Factory
Expand Down Expand Up @@ -55,8 +55,8 @@ def jsonschema(self) -> dict[str, Any]:
version = "0.1.0"

# Timestamps
created_at = LazyFunction(lambda: datetime.now(timezone.utc))
updated_at = LazyFunction(lambda: datetime.now(timezone.utc))
created_at = LazyFunction(lambda: datetime.now(UTC))
updated_at = LazyFunction(lambda: datetime.now(UTC))


class KnowledgeServiceQueryFactory(Factory):
Expand All @@ -75,5 +75,5 @@ class Meta:
prompt = "Extract test data from the document"

# Timestamps
created_at = LazyFunction(lambda: datetime.now(timezone.utc))
updated_at = LazyFunction(lambda: datetime.now(timezone.utc))
created_at = LazyFunction(lambda: datetime.now(UTC))
updated_at = LazyFunction(lambda: datetime.now(UTC))
14 changes: 5 additions & 9 deletions src/julee/contrib/ceap/domain/models/document/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"""

from collections.abc import Callable, Mapping
from datetime import datetime, timezone
from enum import Enum
from datetime import UTC, datetime
from enum import StrEnum
from typing import Any

from pydantic import Field, ValidationInfo, field_validator, model_validator
Expand Down Expand Up @@ -41,7 +41,7 @@ def delegated_method(self: Any, *args: Any, **kwargs: Any) -> Any:
return decorator


class DocumentStatus(str, Enum):
class DocumentStatus(StrEnum):
"""Status of a document through the Capture, Extract, Assemble, Publish
pipeline."""

Expand Down Expand Up @@ -82,12 +82,8 @@ class Document(Entity):
assembly_types: tuple[str, ...] = Field(default_factory=tuple)

# Timestamps
created_at: datetime | None = Field(
default_factory=lambda: datetime.now(timezone.utc)
)
updated_at: datetime | None = Field(
default_factory=lambda: datetime.now(timezone.utc)
)
created_at: datetime | None = Field(default_factory=lambda: datetime.now(UTC))
updated_at: datetime | None = Field(default_factory=lambda: datetime.now(UTC))

# Additional data and content stream
additional_metadata: Mapping[str, Any] = Field(default_factory=dict)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"""

import io
from datetime import datetime, timezone
from datetime import UTC, datetime
from typing import Any

from factory.base import Factory
Expand Down Expand Up @@ -59,8 +59,8 @@ class Meta:
assembly_types: list[str] = []

# Timestamps
created_at = LazyFunction(lambda: datetime.now(timezone.utc))
updated_at = LazyFunction(lambda: datetime.now(timezone.utc))
created_at = LazyFunction(lambda: datetime.now(UTC))
updated_at = LazyFunction(lambda: datetime.now(UTC))

# Additional data
additional_metadata: dict[str, Any] = {}
Expand Down
Loading
Loading