Package ai.djl.repository
Class AbstractRepository
java.lang.Object
ai.djl.repository.AbstractRepository
- All Implemented Interfaces:
Repository
- Direct Known Subclasses:
JarRepository,LocalRepository,RemoteRepository,SimpleRepository,SimpleUrlRepository
The
AbstractRepository is the shared base for implementers of the Repository
interface.- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddResource(MRL mrl) Adds resource to the repository.protected voiddownload(Path tmp, URI baseUri, Artifact.Item item, ai.djl.util.Progress progress) Returns the URI to the base of the repository.Returns the cache directory for the repository.getFile(Artifact.Item item, String path) Returns the path to a file for the item.getName()Returns the repository name.String[]listDirectory(Artifact.Item item, String path) Returns the list of files directly within a specified directory in a zipped directory item.openStream(Artifact.Item item, String path) Returns anInputStreamfor an item in a repository.voidPrepares the artifact for use with progress tracking.protected URIresolvePath(Artifact.Item item, String path) protected voidsave(InputStream is, Path tmp, Artifact.Item item, ai.djl.util.Progress progress) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ai.djl.repository.Repository
dataset, dataset, getResourceDirectory, getResources, isRemote, locate, model, model, model, prepare, resolve
-
Field Details
-
name
-
uri
-
arguments
-
-
Constructor Details
-
AbstractRepository
-
-
Method Details
-
getName
Returns the repository name.- Specified by:
getNamein interfaceRepository- Returns:
- the repository name
-
getBaseUri
Returns the URI to the base of the repository.- Specified by:
getBaseUriin interfaceRepository- Returns:
- the URI
-
openStream
Returns anInputStreamfor an item in a repository.- Specified by:
openStreamin interfaceRepository- Parameters:
item- the item to openpath- the path to a file if the item is a zipped directory. Otherwise, pass null- Returns:
- the file stream
- Throws:
IOException- if it failed to open the stream
-
listDirectory
Returns the list of files directly within a specified directory in a zipped directory item.- Specified by:
listDirectoryin interfaceRepository- Parameters:
item- the zipped directory itempath- the path within the zip directory- Returns:
- the list of files/directories
- Throws:
IOException- if it failed to list the directory
-
getFile
Returns the path to a file for the item.- Specified by:
getFilein interfaceRepository- Parameters:
item- the item to find the path forpath- the path to a file if the item is a zipped directory. Otherwise, pass null- Returns:
- the file path
- Throws:
IOException- if it failed to find the path
-
resolvePath
- Throws:
IOException
-
prepare
Prepares the artifact for use with progress tracking.- Specified by:
preparein interfaceRepository- Parameters:
artifact- the artifact to prepareprogress- the progress tracker- Throws:
IOException- if it failed to prepare
-
getCacheDirectory
Returns the cache directory for the repository.- Specified by:
getCacheDirectoryin interfaceRepository- Returns:
- the cache directory path
- Throws:
IOException- if it failed to ensure the creation of the cache directory
-
addResource
Adds resource to the repository.- Specified by:
addResourcein interfaceRepository- Parameters:
mrl- the resource to add
-
download
protected void download(Path tmp, URI baseUri, Artifact.Item item, ai.djl.util.Progress progress) throws IOException - Throws:
IOException
-
save
protected void save(InputStream is, Path tmp, Artifact.Item item, ai.djl.util.Progress progress) throws IOException - Throws:
IOException
-