Source code for allensdk.api.cloud_cache.file_attributes
import json
import pathlib
[docs]class CacheFileAttributes(object):
"""
This class will contain the attributes of a remotely stored file
so that they can easily and consistently be passed around between
the methods making up the remote file cache and manifest classes
Parameters
----------
url: str
The full URL of the remote file
version_id: str
A string specifying the version of the file (probably calculated
by S3)
file_hash: str
The (hexadecimal) file hash of the file
local_path: pathlib.Path
The path to the location where the file's local copy should be stored
(probably computed by the Manifest class)
"""
def __init__(self,
url: str,
version_id: str,
file_hash: str,
local_path: pathlib.Path):
if not isinstance(url, str):
raise ValueError(f"url must be str; got {type(url)}")
if not isinstance(version_id, str):
raise ValueError(f"version_id must be str; got {type(version_id)}")
if not isinstance(file_hash, str):
raise ValueError(f"file_hash must be str; "
f"got {type(file_hash)}")
if not isinstance(local_path, pathlib.Path):
raise ValueError(f"local_path must be pathlib.Path; "
f"got {type(local_path)}")
self._url = url
self._version_id = version_id
self._file_hash = file_hash
self._local_path = local_path
@property
def url(self) -> str:
return self._url
@property
def version_id(self) -> str:
return self._version_id
@property
def file_hash(self) -> str:
return self._file_hash
@property
def local_path(self) -> pathlib.Path:
return self._local_path
def __str__(self):
output = {'url': self.url,
'version_id': self.version_id,
'file_hash': self.file_hash,
'local_path': str(self.local_path)}
output = json.dumps(output, indent=2, sort_keys=True)
return f'CacheFileParameters{output}'