Class MRL

java.lang.Object
ai.djl.repository.MRL

public final class MRL extends Object
The MRL (Machine learning Resource Locator) is a pointer to a Metadata "resource" on a machine learning Repository.

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 Details

    • model

      public static MRL model(Repository repository, Application application, String groupId, String artifactId, String version, String artifactName)
      Creates a model MRL with specified application.
      Parameters:
      repository - the Repository
      application - the desired application
      groupId - the desired groupId
      artifactId - the desired artifactId
      version - the resource version
      artifactName - the desired artifact name
      Returns:
      a model MRL
    • dataset

      public static MRL dataset(Repository repository, Application application, String groupId, String artifactId, String version)
      Creates a dataset MRL with specified application.
      Parameters:
      repository - the Repository
      application - the desired application
      groupId - the desired groupId
      artifactId - the desired artifactId
      version - the resource version
      Returns:
      a dataset MRL
    • undefined

      public static MRL undefined(Repository repository, String groupId, String artifactId)
      Creates a dataset MRL with specified application.
      Parameters:
      repository - the Repository
      groupId - the desired groupId
      artifactId - the desired artifactId
      Returns:
      a dataset MRL
    • toURI

      public URI toURI()
      Returns the URI to the metadata location (used for Repository 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 String getGroupId()
      Returns the groupId.
      Returns:
      the groupId
    • getArtifactId

      public String getArtifactId()
      Returns the artifactId.
      Returns:
      the artifactId
    • getVersion

      public String getVersion()
      Returns the version.
      Returns:
      the version
    • getDefaultArtifact

      public Artifact getDefaultArtifact() throws IOException
      Returns the default artifact.
      Returns:
      the default artifact
      Throws:
      IOException - for various exceptions depending on the specific dataset
    • match

      public Artifact match(Map<String,String> criteria) throws 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:
      IOException - for errors while loading the model
    • listArtifacts

      public List<Artifact> listArtifacts() throws IOException
      Returns a list of artifacts in this resource.
      Returns:
      a list of artifacts in this resource
      Throws:
      IOException - for errors while loading the model
    • isPrepared

      public boolean isPrepared(Artifact artifact) throws IOException
      Returns true if the artifact is ready for use.
      Parameters:
      artifact - the artifact to prepare
      Returns:
      true if the artifact is ready for use
      Throws:
      IOException - if it failed to prepare
    • prepare

      public void prepare(Artifact artifact) throws IOException
      Prepares the artifact for use.
      Parameters:
      artifact - the artifact to prepare
      Throws:
      IOException - if it failed to prepare
    • prepare

      public void prepare(Artifact artifact, ai.djl.util.Progress progress) throws IOException
      Prepares the artifact for use with progress tracking.
      Parameters:
      artifact - the artifact to prepare
      progress - the progress tracker
      Throws:
      IOException - if it failed to prepare
    • toString

      public String toString()
      Overrides:
      toString in class Object