Table of Contents

Class ArtifactFunctions

Namespace
OptunaSharp.Artifacts
Assembly
OptunaSharp.dll

Module-level artifact functions: upload_artifact, download_artifact, get_all_artifact_meta.

public static class ArtifactFunctions
Inheritance
ArtifactFunctions
Inherited Members

Methods

DownloadArtifact(IArtifactStore, string, string)

Download an artifact from the artifact store (Python download_artifact).

public static void DownloadArtifact(IArtifactStore artifactStore, string filePath, string artifactId)

Parameters

artifactStore IArtifactStore

An artifact store.

filePath string

A path to save the downloaded artifact.

artifactId string

The identifier of the artifact to download.

Remarks

Both streams are disposed on failure, but a partially written destination file is retained.

Exceptions

FileExistsError

The destination already exists, as a file or a directory: Python's FileExistsError("File already exists: …"), NumSharp's class since 0.81.0 (an IOException, so a catch (IOException) still sees it).

IOException

File copying fails.

ArtifactNotFound

The requested artifact does not exist.

UnauthorizedAccessException

The destination cannot be written.

GetAllArtifactMeta(object, BaseStorage?)

List the associated artifact information of the provided trial or study (Python get_all_artifact_meta). If a Study is provided, the artifacts uploaded to the study are returned, not those of all its trials.

public static List<ArtifactMeta> GetAllArtifactMeta(object studyOrTrial, BaseStorage? storage = null)

Parameters

studyOrTrial object

Trial, FrozenTrial, or Study whose artifact metadata is requested.

storage BaseStorage

Storage backend holding study and trial records.

Returns

List<ArtifactMeta>

Metadata attached directly to the supplied study or trial.

Exceptions

ValueError

No storage can be resolved, or stored metadata is not valid JSON.

TypeError

The object is neither Trial, FrozenTrial, nor Study.

InvalidCastException

Stored artifact metadata has an incompatible shape.

KeyNotFoundException

A required metadata field is missing.

UploadArtifact(IArtifactStore, string, object, BaseStorage?, string?, string?)

Upload an artifact to the artifact store (Python upload_artifact).

public static string UploadArtifact(IArtifactStore artifactStore, string filePath, object studyOrTrial, BaseStorage? storage = null, string? mimetype = null, string? encoding = null)

Parameters

artifactStore IArtifactStore

An artifact store.

filePath string

A path to the file to be uploaded.

studyOrTrial object

A Trial, FrozenTrial or Study.

storage BaseStorage

A storage object. Required only if studyOrTrial is a FrozenTrial.

mimetype string

A MIME type of the artifact; guessed from the file extension when omitted.

encoding string

A Content-Encoding of the artifact; guessed from the file extension when omitted.

Returns

string

An artifact ID.

Remarks

Metadata is stored before the content is uploaded. An upload failure can leave metadata pointing to absent or partial content; the operation is not transactional.

Exceptions

ValueError

No storage can be resolved for the supplied object.

TypeError

The object is neither Trial, FrozenTrial, nor Study.

UpdateFinishedTrialError

Metadata is written to a finished trial.

IOException

The local input file cannot be read.

UnauthorizedAccessException

Read access to the input file is denied.

Exception

The artifact or metadata backend fails.