Class SimpleRepository

java.lang.Object
ai.djl.repository.AbstractRepository
ai.djl.repository.SimpleRepository
All Implemented Interfaces:
Repository

public class SimpleRepository extends AbstractRepository
A SimpleRepository is a Repository containing only a single artifact without requiring a "metadata.json" file.
See Also:
  • Constructor Details

    • SimpleRepository

      protected SimpleRepository(String name, URI uri, Path path)
      (Internal) Constructs a SimpleRepository.

      Use Repository.newInstance(String, String).

      Parameters:
      name - the name of the repository
      uri - the base URI of the repository
      path - the path to the repository
  • Method Details

    • isRemote

      public boolean isRemote()
      Returns whether the repository is remote repository.
      Returns:
      whether the repository is remote repository
    • getBaseUri

      public URI getBaseUri()
      Returns the URI to the base of the repository.
      Specified by:
      getBaseUri in interface Repository
      Overrides:
      getBaseUri in class AbstractRepository
      Returns:
      the URI
    • locate

      public Metadata locate(MRL mrl) throws IOException
      Returns the metadata at a mrl.
      Parameters:
      mrl - the mrl of the metadata to retrieve
      Returns:
      the metadata
      Throws:
      IOException - if it failed to load the metadata
    • resolve

      public Artifact resolve(MRL mrl, Map<String,String> filter) throws IOException
      Returns the artifact matching a mrl, version, and property filter.
      Parameters:
      mrl - the mrl to match the artifact against
      filter - the property filter
      Returns:
      the matched artifact
      Throws:
      IOException - if it failed to load the artifact
    • getResourceDirectory

      public Path getResourceDirectory(Artifact artifact) throws IOException
      Returns the resource directory for the an artifact.
      Parameters:
      artifact - the artifact whose resource directory to return
      Returns:
      the resource directory path
      Throws:
      IOException - if it failed to ensure the creation of the cache directory
    • download

      protected void download(Path tmp, URI baseUri, Artifact.Item item, ai.djl.util.Progress progress) throws IOException
      Overrides:
      download in class AbstractRepository
      Throws:
      IOException
    • prepare

      public void prepare(Artifact artifact, ai.djl.util.Progress progress) throws IOException
      Prepares the artifact for use with progress tracking.
      Specified by:
      prepare in interface Repository
      Overrides:
      prepare in class AbstractRepository
      Parameters:
      artifact - the artifact to prepare
      progress - the progress tracker
      Throws:
      IOException - if it failed to prepare
    • getCacheDirectory

      public Path getCacheDirectory() throws IOException
      Returns the cache directory for the repository.
      Specified by:
      getCacheDirectory in interface Repository
      Overrides:
      getCacheDirectory in class AbstractRepository
      Returns:
      the cache directory path
      Throws:
      IOException - if it failed to ensure the creation of the cache directory
    • resolvePath

      protected URI resolvePath(Artifact.Item item, String path) throws IOException
      Overrides:
      resolvePath in class AbstractRepository
      Throws:
      IOException
    • getResources

      public List<MRL> getResources()
      Returns a list of MRLs in the repository.

      An empty list will be returned if underlying Repository implementation does not support this feature.

      Returns:
      a list of MRLs in the repository