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 TypeMethodDescriptionvoid
addResource
(MRL mrl) Adds resource to the repository.protected void
download
(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 anInputStream
for an item in a repository.void
Prepares the artifact for use with progress tracking.protected URI
resolvePath
(Artifact.Item item, String path) protected void
save
(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, wait
Methods 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:
getName
in interfaceRepository
- Returns:
- the repository name
-
getBaseUri
Returns the URI to the base of the repository.- Specified by:
getBaseUri
in interfaceRepository
- Returns:
- the URI
-
openStream
Returns anInputStream
for an item in a repository.- Specified by:
openStream
in 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:
listDirectory
in 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:
getFile
in 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:
prepare
in 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:
getCacheDirectory
in 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:
addResource
in 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
-