Package ai.djl.repository
Class SimpleRepository
- java.lang.Object
-
- ai.djl.repository.AbstractRepository
-
- ai.djl.repository.SimpleRepository
-
- All Implemented Interfaces:
Repository
public class SimpleRepository extends AbstractRepository
ASimpleRepositoryis aRepositorycontaining only a single artifact without requiring a "metadata.json" file.- See Also:
Repository
-
-
Field Summary
-
Fields inherited from class ai.djl.repository.AbstractRepository
arguments, name, uri
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedSimpleRepository(java.lang.String name, java.net.URI uri, java.nio.file.Path path)(Internal) Constructs a SimpleRepository.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voiddownload(java.nio.file.Path tmp, java.net.URI baseUri, Artifact.Item item, ai.djl.util.Progress progress)java.net.URIgetBaseUri()Returns the URI to the base of the repository.java.nio.file.PathgetCacheDirectory()Returns the cache directory for the repository.java.nio.file.PathgetResourceDirectory(Artifact artifact)Returns the resource directory for the an artifact.java.util.List<MRL>getResources()Returns a list ofMRLs in the repository.booleanisRemote()Returns whether the repository is remote repository.Metadatalocate(MRL mrl)Returns the metadata at a mrl.voidprepare(Artifact artifact, ai.djl.util.Progress progress)Prepares the artifact for use with progress tracking.Artifactresolve(MRL mrl, java.util.Map<java.lang.String,java.lang.String> filter)Returns the artifact matching a mrl, version, and property filter.protected java.net.URIresolvePath(Artifact.Item item, java.lang.String path)-
Methods inherited from class ai.djl.repository.AbstractRepository
addResource, getFile, getName, listDirectory, openStream, save
-
-
-
-
Method Detail
-
isRemote
public boolean isRemote()
Returns whether the repository is remote repository.- Returns:
- whether the repository is remote repository
-
getBaseUri
public java.net.URI getBaseUri()
Returns the URI to the base of the repository.- Specified by:
getBaseUriin interfaceRepository- Overrides:
getBaseUriin classAbstractRepository- Returns:
- the URI
-
locate
public Metadata locate(MRL mrl) throws java.io.IOException
Returns the metadata at a mrl.- Parameters:
mrl- the mrl of the metadata to retrieve- Returns:
- the metadata
- Throws:
java.io.IOException- if it failed to load the metadata
-
resolve
public Artifact resolve(MRL mrl, java.util.Map<java.lang.String,java.lang.String> filter) throws java.io.IOException
Returns the artifact matching a mrl, version, and property filter.- Parameters:
mrl- the mrl to match the artifact againstfilter- the property filter- Returns:
- the matched artifact
- Throws:
java.io.IOException- if it failed to load the artifact
-
getResourceDirectory
public java.nio.file.Path getResourceDirectory(Artifact artifact) throws java.io.IOException
Returns the resource directory for the an artifact.- Parameters:
artifact- the artifact whose resource directory to return- Returns:
- the resource directory path
- Throws:
java.io.IOException- if it failed to ensure the creation of the cache directory
-
download
protected void download(java.nio.file.Path tmp, java.net.URI baseUri, Artifact.Item item, ai.djl.util.Progress progress) throws java.io.IOException- Overrides:
downloadin classAbstractRepository- Throws:
java.io.IOException
-
prepare
public void prepare(Artifact artifact, ai.djl.util.Progress progress) throws java.io.IOException
Prepares the artifact for use with progress tracking.- Specified by:
preparein interfaceRepository- Overrides:
preparein classAbstractRepository- Parameters:
artifact- the artifact to prepareprogress- the progress tracker- Throws:
java.io.IOException- if it failed to prepare
-
getCacheDirectory
public java.nio.file.Path getCacheDirectory() throws java.io.IOExceptionReturns the cache directory for the repository.- Specified by:
getCacheDirectoryin interfaceRepository- Overrides:
getCacheDirectoryin classAbstractRepository- Returns:
- the cache directory path
- Throws:
java.io.IOException- if it failed to ensure the creation of the cache directory
-
resolvePath
protected java.net.URI resolvePath(Artifact.Item item, java.lang.String path) throws java.io.IOException
- Overrides:
resolvePathin classAbstractRepository- Throws:
java.io.IOException
-
-