Package ai.djl.repository
Class MRL
- java.lang.Object
-
- ai.djl.repository.MRL
-
public final class MRL extends java.lang.Object
TheMRL
(Machine learning Resource Locator) is a pointer to aMetadata
"resource" on a machine learningRepository
.Each mrl references a single metadata file (parsed to
Metadata
and the collection of artifacts located within it. Those artifacts all share the same groupId and artifactId, but can differ based on the name and properties.The mrl consists of three different properties:
- type - The resource type, e.g. model or dataset.
- application - The resource application (See
Application
). - groupId - The group id identifies the group publishing the artifacts using a reverse domain name system.
- artifactId - The artifact id identifies the different artifacts published by a single group.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static MRL
dataset(Repository repository, Application application, java.lang.String groupId, java.lang.String artifactId, java.lang.String version)
Creates a datasetMRL
with specified application.Application
getApplication()
Returns the application.java.lang.String
getArtifactId()
Returns the artifactId.Artifact
getDefaultArtifact()
Returns the default artifact.java.lang.String
getGroupId()
Returns the groupId.Repository
getRepository()
Returns the repository.java.lang.String
getVersion()
Returns the version.java.util.List<Artifact>
listArtifacts()
Returns a list of artifacts in this resource.Artifact
match(java.util.Map<java.lang.String,java.lang.String> criteria)
Returns the first artifact that matches a given criteria.static MRL
model(Repository repository, Application application, java.lang.String groupId, java.lang.String artifactId, java.lang.String version, java.lang.String artifactName)
Creates a modelMRL
with specified application.void
prepare(Artifact artifact)
Prepares the artifact for use.void
prepare(Artifact artifact, ai.djl.util.Progress progress)
Prepares the artifact for use with progress tracking.java.lang.String
toString()
java.net.URI
toURI()
Returns the URI to the metadata location (used forRepository
implementations).static MRL
undefined(Repository repository, java.lang.String groupId, java.lang.String artifactId)
Creates a datasetMRL
with specified application.
-
-
-
Method Detail
-
model
public static MRL model(Repository repository, Application application, java.lang.String groupId, java.lang.String artifactId, java.lang.String version, java.lang.String artifactName)
Creates a modelMRL
with specified application.- Parameters:
repository
- theRepository
application
- the desired applicationgroupId
- the desired groupIdartifactId
- the desired artifactIdversion
- the resource versionartifactName
- the desired artifact name- Returns:
- a model
MRL
-
dataset
public static MRL dataset(Repository repository, Application application, java.lang.String groupId, java.lang.String artifactId, java.lang.String version)
Creates a datasetMRL
with specified application.- Parameters:
repository
- theRepository
application
- the desired applicationgroupId
- the desired groupIdartifactId
- the desired artifactIdversion
- the resource version- Returns:
- a dataset
MRL
-
undefined
public static MRL undefined(Repository repository, java.lang.String groupId, java.lang.String artifactId)
Creates a datasetMRL
with specified application.- Parameters:
repository
- theRepository
groupId
- the desired groupIdartifactId
- the desired artifactId- Returns:
- a dataset
MRL
-
toURI
public java.net.URI toURI()
Returns the URI to the metadata location (used forRepository
implementations).- Returns:
- the URI to the metadata location
-
getRepository
public Repository getRepository()
Returns the repository.- Returns:
- the repository
-
getApplication
public Application getApplication()
Returns the application.- Returns:
- the application
-
getGroupId
public java.lang.String getGroupId()
Returns the groupId.- Returns:
- the groupId
-
getArtifactId
public java.lang.String getArtifactId()
Returns the artifactId.- Returns:
- the artifactId
-
getVersion
public java.lang.String getVersion()
Returns the version.- Returns:
- the version
-
getDefaultArtifact
public Artifact getDefaultArtifact() throws java.io.IOException
Returns the default artifact.- Returns:
- the default artifact
- Throws:
java.io.IOException
- for various exceptions depending on the specific dataset
-
match
public Artifact match(java.util.Map<java.lang.String,java.lang.String> criteria) throws java.io.IOException
Returns the first artifact that matches a given criteria.- Parameters:
criteria
- the criteria to match against- Returns:
- the first artifact that matches the criteria. Null will be returned if no artifact matches
- Throws:
java.io.IOException
- for errors while loading the model
-
listArtifacts
public java.util.List<Artifact> listArtifacts() throws java.io.IOException
Returns a list of artifacts in this resource.- Returns:
- a list of artifacts in this resource
- Throws:
java.io.IOException
- for errors while loading the model
-
prepare
public void prepare(Artifact artifact) throws java.io.IOException
Prepares the artifact for use.- Parameters:
artifact
- the artifact to prepare- Throws:
java.io.IOException
- if it failed to prepare
-
prepare
public void prepare(Artifact artifact, ai.djl.util.Progress progress) throws java.io.IOException
Prepares the artifact for use with progress tracking.- Parameters:
artifact
- the artifact to prepareprogress
- the progress tracker- Throws:
java.io.IOException
- if it failed to prepare
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-