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
10 changes: 5 additions & 5 deletions artlink/artifact.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
from pydantic import ConfigDict, Field, ValidationError, field_serializer, field_validator, model_validator

__all__ = (
"Artifact",
"ArtifactInferenceIssue",
"ArtlinkError",
"ManifestError",
"Digest",
"Capability",
"ArtifactInferenceIssue",
"Digest",
"ManifestError",
"Reference",
"Artifact",
"artifact_inference_issues",
"capability_from_value",
"has_capability",
Expand Down Expand Up @@ -199,7 +199,7 @@ def _validate_capabilities(cls, value: tuple[CapabilityValue, ...]) -> tuple[Cap
return tuple(value)

@model_validator(mode="after")
def _validate_location(self) -> "Artifact":
def _validate_location(self) -> Artifact:
if self.path is None and not self.uri:
raise ValueError("artifact must declare a path or uri")
return self
Expand Down
2 changes: 1 addition & 1 deletion artlink/examples/domains/docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
from ...resolver import ResolutionPlan

__all__ = (
"ToolRequirement",
"DocumentationSiteCollection",
"DocumentationSiteScheme",
"ToolRequirement",
)


Expand Down
2 changes: 1 addition & 1 deletion artlink/examples/domains/hdl.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
from ...resolver import ResolutionPlan

__all__ = (
"ToolRequirement",
"HardwareDesignCollection",
"HardwareProjectScheme",
"ToolRequirement",
)


Expand Down
2 changes: 1 addition & 1 deletion artlink/examples/domains/ml.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
from ...resolver import ResolutionPlan

__all__ = (
"ToolRequirement",
"ModelReleaseCollection",
"ModelReleaseScheme",
"ToolRequirement",
)


Expand Down
2 changes: 1 addition & 1 deletion artlink/examples/domains/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
from ...resolver import ResolutionPlan

__all__ = (
"ToolRequirement",
"PythonPackageCollection",
"PythonPackageScheme",
"ToolRequirement",
)


Expand Down
4 changes: 2 additions & 2 deletions artlink/manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
"ARTLINK_MANIFEST_SCHEMA",
"Manifest",
"artifact_path",
"manifest_from_mapping",
"load_manifest",
"manifest_from_mapping",
"validate_artifact_files",
)

Expand Down Expand Up @@ -61,7 +61,7 @@ def _validate_unique_artifacts(self) -> Self:
return self

@classmethod
def compose(cls, *, name: str, manifests: tuple["Manifest", ...], intent: str = "", metadata: dict[str, Any] | None = None) -> "Manifest":
def compose(cls, *, name: str, manifests: tuple[Manifest, ...], intent: str = "", metadata: dict[str, Any] | None = None) -> Manifest:
composed_metadata = dict(metadata or {})
composed_metadata.setdefault("composed_from", [manifest.name for manifest in manifests])
artifacts = tuple(artifact for manifest in manifests for artifact in manifest.artifacts)
Expand Down
2 changes: 1 addition & 1 deletion artlink/materialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
from .resolver import ResolutionPlan

__all__ = (
"MaterializationAction",
"MaterializationError",
"MaterializationMethod",
"MaterializationAction",
"MaterializationPlan",
"MaterializationResult",
"build_materialization_plan",
Expand Down
30 changes: 15 additions & 15 deletions artlink/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
from .template import Template, load_template

__all__ = (
"ARTLINK_REGISTRY_SCHEMA",
"ARTLINK_INSTALL_SUBDIR",
"ARTLINK_MANIFEST_ENTRY_POINT_GROUP",
"ARTLINK_REGISTRY_SCHEMA",
"MANIFEST_INSTALL_SUBDIR",
"RegistryError",
"ArtifactRegistry",
"ArtifactRegistryEntry",
"ManifestRegistryEntry",
"RegistryError",
"TemplateRegistryEntry",
"ArtifactRegistryEntry",
"ArtifactRegistry",
"artlink_install_dir",
"load_registry",
"manifest_install_dir",
Expand Down Expand Up @@ -102,7 +102,7 @@ def from_manifests(
source: str = "explicit",
root: Path | None = None,
allow_manifest_versions: bool = False,
) -> "ArtifactRegistry":
) -> ArtifactRegistry:
registry = cls(allow_manifest_versions=allow_manifest_versions)
for manifest in manifests:
registry.register_manifest(manifest, source=source, root=root)
Expand All @@ -116,17 +116,17 @@ def from_manifest_files(
source: str | None = None,
root: Path | None = None,
allow_manifest_versions: bool = False,
) -> "ArtifactRegistry":
) -> ArtifactRegistry:
registry = cls(allow_manifest_versions=allow_manifest_versions)
for path in paths:
registry.register_manifest_file(path, source=source, root=root)
return registry

@classmethod
def from_install_path(cls, root: Path | None = None, *, allow_manifest_versions: bool = False) -> "ArtifactRegistry":
def from_install_path(cls, root: Path | None = None, *, allow_manifest_versions: bool = False) -> ArtifactRegistry:
return cls(allow_manifest_versions=allow_manifest_versions).discover_install_path(root)

def register_manifest(self, manifest: Manifest, *, source: str = "explicit", root: Path | None = None) -> "ArtifactRegistry":
def register_manifest(self, manifest: Manifest, *, source: str = "explicit", root: Path | None = None) -> ArtifactRegistry:
manifest_key = (manifest.name, manifest.version)
registration_root = Path(root) if root is not None else None
if manifest_key in self._manifests or (not self.allow_manifest_versions and self._entries_for_name(manifest.name)):
Expand All @@ -136,21 +136,21 @@ def register_manifest(self, manifest: Manifest, *, source: str = "explicit", roo
self.register_artifact(artifact, source=source, manifest_name=manifest.name, manifest_version=manifest.version, root=registration_root)
return self

def register_manifest_file(self, path: Path, *, source: str | None = None, root: Path | None = None) -> "ArtifactRegistry":
def register_manifest_file(self, path: Path, *, source: str | None = None, root: Path | None = None) -> ArtifactRegistry:
manifest_path = Path(path)
manifest_source = source or manifest_path.as_posix()
registration_root = manifest_path.parent if root is None else Path(root)
return self.register_manifest(load_manifest(manifest_path), source=manifest_source, root=registration_root)

def register_template(self, template: Template, *, source: str = "explicit", root: Path | None = None) -> "ArtifactRegistry":
def register_template(self, template: Template, *, source: str = "explicit", root: Path | None = None) -> ArtifactRegistry:
template_key = (template.name, template.version)
registration_root = Path(root) if root is not None else None
if template_key in self._templates or (not self.allow_template_versions and self._template_entries_for_name(template.name)):
raise RegistryError(f"duplicate template registration: {template.name}")
self._templates[template_key] = TemplateRegistryEntry(template=template, source=source, root=registration_root)
return self

def register_template_file(self, path: Path, *, source: str | None = None, root: Path | None = None) -> "ArtifactRegistry":
def register_template_file(self, path: Path, *, source: str | None = None, root: Path | None = None) -> ArtifactRegistry:
template_path = Path(path)
template_source = source or template_path.as_posix()
registration_root = template_path.parent if root is None else Path(root)
Expand All @@ -164,7 +164,7 @@ def register_artifact(
manifest_name: str = "",
manifest_version: str = "",
root: Path | None = None,
) -> "ArtifactRegistry":
) -> ArtifactRegistry:
registration_root = Path(root) if root is not None else None
self._artifacts.append(
ArtifactRegistryEntry(
Expand All @@ -177,7 +177,7 @@ def register_artifact(
)
return self

def discover_install_path(self, root: Path | None = None) -> "ArtifactRegistry":
def discover_install_path(self, root: Path | None = None) -> ArtifactRegistry:
install_prefix = _install_prefix(root)
return self.discover_manifest_files(artlink_install_dir(install_prefix))

Expand All @@ -187,7 +187,7 @@ def discover_manifest_files(
*,
patterns: tuple[str, ...] = _MANIFEST_FILE_PATTERNS,
root: Path | None = None,
) -> "ArtifactRegistry":
) -> ArtifactRegistry:
manifest_dir = Path(directory)
if not manifest_dir.exists():
return self
Expand All @@ -207,7 +207,7 @@ def discover_entry_points(
*,
group: str = ARTLINK_MANIFEST_ENTRY_POINT_GROUP,
entry_points: Any | None = None,
) -> "ArtifactRegistry":
) -> ArtifactRegistry:
for entry_point in _select_entry_points(group=group, entry_points=entry_points):
source = f"entry-point:{entry_point.name}"
value = entry_point.load()
Expand Down
6 changes: 3 additions & 3 deletions artlink/resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
from .template import Template

__all__ = (
"ResolutionError",
"ProviderConflictPolicy",
"CapabilityProvider",
"ProviderConflictPolicy",
"ResolutionEdge",
"ResolutionError",
"ResolutionIssue",
"ResolutionNode",
"ResolutionEdge",
"ResolutionPlan",
"resolve_manifest",
)
Expand Down
12 changes: 5 additions & 7 deletions artlink/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@

__all__ = (
"ARTLINK_TEMPLATE_SCHEMA",
"TemplateError",
"ArtifactSelector",
"Cardinality",
"Template",
"TemplateError",
"TemplateRule",
"ValidationIssue",
"ValidationResult",
"Template",
"template_from_mapping",
"load_template",
"template_from_mapping",
)


Expand Down Expand Up @@ -113,9 +113,7 @@ def _validate_range(self) -> Self:
def allows(self, count: int) -> bool:
if count < self.min:
return False
if self.max is not None and count > self.max:
return False
return True
return not (self.max is not None and count > self.max)

def describe_failure(self, count: int) -> str:
if count < self.min:
Expand Down Expand Up @@ -218,7 +216,7 @@ def to_yaml_text(self) -> str:
return yaml.safe_dump(self.model_dump(mode="json"), sort_keys=False)

@classmethod
def load(cls, path: Path) -> "Template":
def load(cls, path: Path) -> Template:
return load_template(path)


Expand Down
3 changes: 1 addition & 2 deletions artlink/tests/integration/test_python_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ def test_python_package_scheme_collects_hatch_built_distributions(tmp_path: Path
[sys.executable, "-m", "build", "--sdist", "--wheel", "--no-isolation", "--outdir", "dist"],
cwd=project_root,
check=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
capture_output=True,
text=True,
)

Expand Down
2 changes: 1 addition & 1 deletion artlink/tests/test_all.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from artlink import * # noqa
from artlink import *


def test_all():
Expand Down