Skip to content

Commit 397eede

Browse files
committed
Paired mlflow data structures to types
1 parent 6d9bfeb commit 397eede

File tree

8 files changed

+294
-230
lines changed

8 files changed

+294
-230
lines changed

src/types/artifact.jl

Lines changed: 10 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,14 @@
11
"""
2-
MLFlowArtifactFileInfo
3-
4-
Metadata of a single artifact file -- result of [`listartifacts`](@ref).
2+
FileInfo
53
64
# Fields
7-
- `filepath::String`: File path, including the root artifact directory of a run.
8-
- `filesize::Int64`: Size in bytes.
9-
"""
10-
struct MLFlowArtifactFileInfo
11-
filepath::String
12-
filesize::Int64
13-
end
14-
Base.show(io::IO, t::MLFlowArtifactFileInfo) = show(io, ShowCase(t, new_lines=true))
15-
get_path(mlfafi::MLFlowArtifactFileInfo) = mlfafi.filepath
16-
get_size(mlfafi::MLFlowArtifactFileInfo) = mlfafi.filesize
17-
18-
"""
19-
MLFlowArtifactDirInfo
20-
21-
Metadata of a single artifact directory -- result of [`listartifacts`](@ref).
22-
23-
# Fields
24-
- `dirpath::String`: Directory path, including the root artifact directory of a run.
25-
"""
26-
struct MLFlowArtifactDirInfo
27-
dirpath::String
5+
- `path::String`: Path relative to the root artifact directory run.
6+
- `is_dir::Bool`: Whether the path is a directory.
7+
- `file_size::Int64`: Size in bytes. Unset for directories.
8+
"""
9+
struct FileInfo
10+
path::String
11+
is_dir::Bool
12+
file_size::Int64
2813
end
29-
Base.show(io::IO, t::MLFlowArtifactDirInfo) = show(io, ShowCase(t, new_lines=true))
30-
get_path(mlfadi::MLFlowArtifactDirInfo) = mlfadi.dirpath
31-
get_size(mlfadi::MLFlowArtifactDirInfo) = 0
14+
Base.show(io::IO, t::FileInfo) = show(io, ShowCase(t, new_lines=true))

src/types/dataset.jl

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
"""
2+
Dataset
3+
4+
Represents a reference to data used for training, testing, or evaluation during
5+
the model development process.
6+
7+
# Fields
8+
- `name::String`: The name of the dataset.
9+
- `digest::String`: The digest of the dataset.
10+
- `source_type::String`: The type of the dataset source.
11+
- `source::String`: Source information for the dataset.
12+
- `schema::String`: The schema of the dataset. This field is optional.
13+
- `profile::String`: The profile of the dataset. This field is optional.
14+
15+
# Constructors
16+
- `Dataset(name, digest, source_type, source, schema, profile)`
17+
- `Dataset(name, digest, source_type, source; schema=nothing, profile=nothing)`
18+
"""
19+
struct Dataset
20+
name::String
21+
digest::String
22+
source_type::String
23+
source::String
24+
schema::Union{String, Nothing}
25+
profile::Union{String, Nothing}
26+
end
27+
Dataset(name, digest, source_type, source; schema=nothing, profile=nothing) =
28+
Dataset(name, digest, source_type, source, schema, profile)
29+
Base.show(io::IO, t::Dataset) = show(io, ShowCase(t, new_lines=true))
30+
31+
"""
32+
DatasetInput
33+
34+
Represents a dataset and input tags.
35+
36+
# Fields
37+
- `tags::Array{Tag}`: A list of tags for the dataset input.
38+
- `dataset::Dataset`: The dataset being used as a Run input.
39+
40+
# Constructors
41+
- `DatasetInput(tags, dataset)`
42+
- `DatasetInput(dataset; tags=[])`
43+
"""
44+
struct DatasetInput
45+
tags::Array{Tag}
46+
dataset::Dataset
47+
end
48+
DatasetInput(dataset; tags=[]) = DatasetInput(tags, dataset)
49+
Base.show(io::IO, t::DatasetInput) = show(io, ShowCase(t, new_lines=true))

src/types/enums.jl

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
"""
2+
ModelVersionStatus
3+
4+
# Members
5+
- `PENDING_REGISTRATION`: Request to register a new model version is pending as
6+
server performs background tasks.
7+
- `FAILED_REGISTRATION`: Request to register a new model version has failed.
8+
- `READY`: Model version is ready for use.
9+
"""
10+
@enum ModelVersionStatus begin
11+
PENDING_REGISTRATION
12+
FAILED_REGISTRATION
13+
READY
14+
end
15+
16+
"""
17+
RunStatus
18+
19+
Status of a run.
20+
21+
# Members
22+
- `RUNNING`: Run has been initiated.
23+
- `SCHEDULED`: Run is scheduled to run at a later time.
24+
- `FINISHED`: Run has completed.
25+
- `FAILED`: Run execution failed.
26+
- `KILLED`: Run killed by user.
27+
"""
28+
@enum RunStatus begin
29+
RUNNING
30+
SCHEDULED
31+
FINISHED
32+
FAILED
33+
KILLED
34+
end
35+
36+
"""
37+
ViewType
38+
39+
View type for ListExperiments query.
40+
41+
# Members
42+
- `ACTIVE_ONLY`: Default. Return only active experiments.
43+
- `DELETED_ONLY`: Return only deleted experiments.
44+
- `ALL`: Get all experiments.
45+
"""
46+
@enum ViewType begin
47+
ACTIVE_ONLY
48+
DELETED_ONLY
49+
ALL
50+
end

src/types/experiment.jl

Lines changed: 17 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,24 @@
11
"""
2-
MLFlowExperiment
3-
4-
Represents an MLFlow experiment.
2+
Experiment
53
64
# Fields
7-
- `name::String`: experiment name.
8-
- `lifecycle_stage::String`: life cycle stage, one of ["active", "deleted"]
9-
- `experiment_id::Integer`: experiment identifier.
10-
- `tags::Any`: list of tags.
11-
- `artifact_location::String`: where are experiment artifacts stored.
12-
13-
# Constructors
14-
15-
- `MLFlowExperiment(name, lifecycle_stage, experiment_id, tags, artifact_location)`
16-
- `MLFlowExperiment(exp::Dict{String,Any})`
17-
5+
- `experiment_id::Integer`: Unique identifier for the experiment.
6+
- `name::String`: Human readable name that identifies the experiment.
7+
- `artifact_location::String`: Location where artifacts for the experiment are
8+
stored.
9+
- `lifecycle_stage::String`: Current life cycle stage of the experiment:
10+
“active” or “deleted”. Deleted experiments are not returned by APIs.
11+
- `last_update_time::Int64`: Last update time.
12+
- `creation_time::Int64`: Creation time.
13+
- `tags::Array{Tag}`: Additional metadata key-value pairs.
1814
"""
19-
struct MLFlowExperiment
15+
struct Experiment
16+
experiment_id::String
2017
name::String
21-
lifecycle_stage::String
22-
experiment_id::Integer
23-
tags::Any
2418
artifact_location::String
19+
lifecycle_stage::String
20+
last_update_time::Int64
21+
creation_time::Int64
22+
tags::Array{Tag}
2523
end
26-
function MLFlowExperiment(exp::Dict{String,Any})
27-
name = get(exp, "name", missing)
28-
lifecycle_stage = get(exp, "lifecycle_stage", missing)
29-
experiment_id = parse(Int, get(exp, "experiment_id", missing))
30-
tags = get(exp, "tags", missing)
31-
artifact_location = get(exp, "artifact_location", missing)
32-
MLFlowExperiment(name, lifecycle_stage, experiment_id, tags, artifact_location)
33-
end
34-
Base.show(io::IO, t::MLFlowExperiment) = show(io, ShowCase(t, new_lines=true))
24+
Base.show(io::IO, t::Experiment) = show(io, ShowCase(t, new_lines=true))

src/types/model_version.jl

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
"""
2+
ModelVersion
3+
4+
# Fields
5+
- `name::String`: Unique name of the model.
6+
- `version::String`: Model’s version number.
7+
- `creation_timestamp::Int64`: Timestamp recorded when this model_version was
8+
created.
9+
- `last_updated_timestamp::Int64`: Timestamp recorded when metadata for this
10+
model_version was last updated.
11+
- `user_id::String`: User that created this model_version.
12+
- `current_stage::String`: Current stage for this model_version.
13+
- `description::String`: Description of this model_version.
14+
- `source::String`: URI indicating the location of the source model artifacts,
15+
used when creating model_version.
16+
- `run_id::String`: MLflow run ID used when creating model_version, if source
17+
was generated by an experiment run stored in MLflow tracking server.
18+
- `status::ModelVersionStatus`: Current status of model_version.
19+
- `status_message::String`: Details on current status, if it is pending or
20+
failed.
21+
- `tags::Array{Tag}`: Additional metadata key-value pairs.
22+
- `run_link::String`: Direct link to the run that generated this version. This
23+
field is set at model version creation time only for model versions whose
24+
source run is from a tracking server that is different from the registry
25+
server.
26+
- `aliases::Array{String}`: Aliases pointing to this model_version.
27+
"""
28+
struct ModelVersion
29+
name::String
30+
version::String
31+
creation_timestamp::Int64
32+
last_updated_timestamp::Int64
33+
user_id::String
34+
current_stage::String
35+
description::String
36+
source::String
37+
run_id::String
38+
status::ModelVersionStatus
39+
status_message::String
40+
tags::Array{Tag}
41+
run_link::String
42+
aliases::Array{String}
43+
end
44+
Base.show(io::IO, t::ModelVersion) = show(io, ShowCase(t, new_lines=true))

src/types/registered_model.jl

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
"""
2+
RegisteredModelAlias
3+
4+
Alias for a registered model.
5+
6+
# Fields
7+
- `alias::String`: The name of the alias.
8+
- `version::String`: The model version number that the alias points to.
9+
"""
10+
struct RegisteredModelAlias
11+
alias::String
12+
version::String
13+
end
14+
Base.show(io::IO, t::RegisteredModelAlias) = show(io, ShowCase(t, new_lines=true))
15+
16+
"""
17+
RegisteredModel
18+
19+
# Fields
20+
- `name::String`: Unique name for the model.
21+
- `creation_timestamp::Int64`: Timestamp recorded when this RegisteredModel was
22+
created.
23+
- `last_updated_timestamp::Int64`: Timestamp recorded when metadata for this
24+
RegisteredModel was last updated.
25+
- `user_id::String`: User that created this RegisteredModel.
26+
- `description::String`: Description of this RegisteredModel.
27+
- `latest_versions::Array{ModelVersion}`: Collection of latest model versions
28+
for each stage. Only contains models with current READY status.
29+
- `tags::Array{Tag}`: Additional metadata key-value pairs.
30+
- `aliases::Array{RegisteredModelAlias}`: Aliases pointing to model versions
31+
associated with this RegisteredModel.
32+
"""
33+
struct RegisteredModel
34+
name::String
35+
creation_timestamp::Int64
36+
last_updated_timestamp::Int64
37+
user_id::String
38+
description::String
39+
latest_versions::Array{ModelVersion}
40+
tags::Array{Tag}
41+
aliases::Array{RegisteredModelAlias}
42+
end
43+
Base.show(io::IO, t::RegisteredModel) = show(io, ShowCase(t, new_lines=true))

0 commit comments

Comments
 (0)