Artifact#
- class Artifact#
Reader for OMMX Artifacts.
An artifact is an OCI container image that stores OMMX data (instances, solutions, sample sets, etc.) as layers.
>>> artifact = Artifact.load("ghcr.io/jij-inc/ommx/random_lp_instance:4303c7f") >>> print(artifact.image_name) ghcr.io/jij-inc/ommx/random_lp_instance:4303c7f
- get_dataframe(descriptor: Descriptor) Any#
Get a pandas DataFrame from an artifact layer stored by
add_dataframe().
- get_instance(descriptor: Optional[Descriptor] = None) Instance#
Get an instance from the artifact.
If
descriptorisNone, returns the first instance layer.If
descriptoris given, returns the instance for that specific layer.
Raises
ValueErrorif no instance layer is found.
- get_json(descriptor: Descriptor) Any#
Get a JSON object from an artifact layer stored by
add_json().
- get_layer(descriptor: Descriptor) Any#
Get the layer object corresponding to the descriptor.
Dynamically dispatched based on
media_type:
- get_layer_descriptor(digest: str) Descriptor#
Look up a layer descriptor by digest.
- get_ndarray(descriptor: Descriptor) Any#
Get a numpy array from an artifact layer stored by
add_ndarray().
- get_parametric_instance(descriptor: Optional[Descriptor] = None) ParametricInstance#
Get a parametric instance from the artifact.
If
descriptorisNone, returns the first parametric instance layer.If
descriptoris given, returns the parametric instance for that specific layer.
Raises
ValueErrorif no parametric instance layer is found.
- get_sample_set(descriptor: Optional[Descriptor] = None) SampleSet#
Get a sample set from the artifact.
If
descriptorisNone, returns the first sample set layer.If
descriptoris given, returns the sample set for that specific layer.
Raises
ValueErrorif no sample set layer is found.
- get_solution(descriptor: Optional[Descriptor] = None) Solution#
Get a solution from the artifact.
If
descriptorisNone, returns the first solution layer.If
descriptoris given, returns the solution for that specific layer.
Raises
ValueErrorif no solution layer is found.
- load(image_name: str) Artifact#
Load an artifact stored as a container image in local or remote registry.
If the image is not found in local registry, it will try to pull from remote registry.
>>> artifact = Artifact.load("ghcr.io/jij-inc/ommx/random_lp_instance:4303c7f") >>> print(artifact.image_name) ghcr.io/jij-inc/ommx/random_lp_instance:4303c7f
- load_archive(path: str | PathLike | Path) Artifact#
Load an artifact stored as a single file or directory.
>>> artifact = Artifact.load_archive("data/random_lp_instance.ommx") >>> print(artifact.image_name) ghcr.io/jij-inc/ommx/random_lp_instance:...
- push() None#
Push the artifact to remote registry.
- property annotations: dict[str, str]#
Read-only property.
Annotations in the artifact manifest.
- property instance: Instance#
Read-only property.
The first instance layer in the artifact.
Raises
ValueErrorif no instance layer is found. For multiple instance layers, useget_instance()with a descriptor.
- property layers: list[Descriptor]#
Read-only property.
- property parametric_instance: ParametricInstance#
Read-only property.
The first parametric instance layer in the artifact.
Raises
ValueErrorif no parametric instance layer is found. For multiple parametric instance layers, useget_parametric_instance()with a descriptor.
- property sample_set: SampleSet#
Read-only property.
The first sample set layer in the artifact.
Raises
ValueErrorif no sample set layer is found. For multiple sample set layers, useget_sample_set()with a descriptor.
- property solution: Solution#
Read-only property.
The first solution layer in the artifact.
Raises
ValueErrorif no solution layer is found. For multiple solution layers, useget_solution()with a descriptor.