Lookup¶
- class audfactory.Lookup(server, repository, group_id, *, name='lookup', version=None)[source]¶
Lookup table for managing artifact flavors on Artifactory.
It creates one row for every flavor, and assigns a unique ID to it. The columns are parameters associated with the flavor. The parameter names are stored as column headers. The column values can be of type
bool
,float
,int
,NoneType
,str
. You cannot use strings that would be converted to any of the other types like'None'
,'True'
,'False'
,'4.0'
, and'4'
.The following code converts an
audfactory.Lookup
object into apandas.DataFrame
:index, data = [], [] if len(lookup.table) > 1: index = [entry[0] for entry in lookup.table[1:]] data = [entry[1:] for entry in lookup.table[1:]] df = pd.DataFrame(data=data, index=index, columns=lookup.columns)
- Parameters
- Raises
RuntimeError – if no lookup tables or no lookup table with the specified version can be found
Examples
>>> lookup = Lookup( ... 'https://artifactory.audeering.com/artifactory', ... 'models-public-local', ... 'com.audeering.models.gender.voxcnn', ... version='0.2.0', ... ) >>> lookup id purpose sampling_rate train-db 3bb24968-759a-11ea-ab25-309c2364e602 prod 16000 voxceleb1 >>> lookup.table [['id', 'purpose', 'sampling_rate', 'train-db'], ['3bb24968-759a-11ea-ab25-309c2364e602', 'prod', 16000, 'voxceleb1']] >>> lookup['3bb24968-759a-11ea-ab25-309c2364e602'] {'purpose': 'prod', 'sampling_rate': 16000, 'train-db': 'voxceleb1'}
__getitem__()¶
append()¶
- Lookup.append(params)[source]¶
Append entry to lookup table.
The lookup table entry gets a unique ID from
params
,self.name
,self.group_id
,self.version
, andself.repository
.- Parameters
params (
Dict
[str
,Any
]) – lookup table entry in the form of{column: parameter}
- Return type
- Returns
ID of added lookup table entry
- Raises
RuntimeError – if entry for given
params
exists already, or the columnsparams
do not match the columns of the lookupValueError – if
params
contain unsupported data types
contains()¶
create()¶
- static Lookup.create(server, repository, group_id, version, params=(), *, name='lookup', force=False)[source]¶
Create lookup table on server.
- Parameters
server (
str
) – URL of Artifactory server, e.g. https://audeering.jfrog.io/artifactoryrepository (
str
) – repository of lookup tablegroup_id (
str
) – group ID of lookup tableversion (
str
) – version of lookup tablename (
str
) – name of lookup tableforce (
bool
) – ifTrue
an existing lookup table is overwritten
- Return type
- Returns
URL of lookup table
- Raises
RuntimeError – if lookup table exists already and
force=False
delete()¶
- static Lookup.delete(server, repository, group_id, version, *, name='lookup', force=True)[source]¶
Delete lookup table on server.
- Parameters
server (
str
) – URL of Artifactory server, e.g. https://audeering.jfrog.io/artifactoryrepository (
str
) – repository of lookup tablegroup_id (
str
) – group ID of lookup tableversion (
str
) – version of lookup tablename (
str
) – name of lookup tableforce (
bool
) – ifTrue
removes lookup table even if not empty
- Raises
RuntimeError – if lookup table is not empty and
force=False
- Return type
exists()¶
- static Lookup.exists(server, repository, group_id, version, *, name='lookup')[source]¶
Check if lookup table exists on server.
- Parameters
- Return type
- Returns
True
if lookup table exists
Examples
>>> Lookup.exists( ... 'https://artifactory.audeering.com/artifactory', ... 'models-public-local', ... 'com.audeering.models.gender.voxcnn', ... '0.1.0', ... ) True
extend()¶
find()¶
generate_uid()¶
- static Lookup.generate_uid(*, params, name, group_id, version, repository)[source]¶
Generate unique ID.
It converts
params
to a string, and concatenates it withname
,group_id
,version
, andrepository
. From that concatenated string a unique ID is derived.- Parameters
- Return type
- Returns
unique identifier of length 36
Examples
>>> Lookup.generate_uid( ... params={0: None}, ... name='name', ... group_id='group.id', ... version='1.0.0', ... repository='models-public-local', ... ) 'afe694a5-8bad-4dbc-73ba-636f18340615'
latest_version()¶
- static Lookup.latest_version(server, repository, group_id, *, params=None, name='lookup')[source]¶
Latest version of lookup table on server.
- Parameters
- Return type
- Returns
latest version of lookup table
Examples
>>> Lookup.latest_version( ... 'https://artifactory.audeering.com/artifactory', ... 'models-public-local', ... 'com.audeering.models.gender.voxcnn', ... ) '0.2.0'
remove()¶
versions()¶
- static Lookup.versions(server, repository, group_id, params=None, *, name='lookup')[source]¶
Available versions of lookup table on server.
- Parameters
- Return type
- Returns
available versions of lookup table
Examples
>>> Lookup.versions( ... 'https://artifactory.audeering.com/artifactory', ... 'models-public-local', ... 'com.audeering.models.gender.voxcnn', ... ) ['0.1.0', '0.2.0']