Studio Interface¶
- autonlu.login(user=None, password=None, baseurl=None)¶
Retrieves and sets the product key from user name and password. The product key will be in effect until
login()
is called again or the Python process ends- Parameters
user (
Optional
[str
]) – User/Email for login. If not specified, a prompt will ask for itpassword (
Optional
[str
]) – Password for login. If not specified, a password prompt will ask for itbaseurl (
Optional
[str
]) – Base url of the studio instance used for this call. IfNone
, the environment variableDO_BASEURL
will be used. IfDO_BASEURL
is not defined, the standard base-url will be used.
Examples:
>>> import autonlu >>> autonlu.login("admin") # Will prompt for password >>> # AutoNLU can be used until the end of the session (until the Python process ends)
- Raises
LoginException if the login failed –
- autonlu.get_product_key(user=None, password=None, baseurl=None)¶
Retrieves the product key for a user from studio
- Parameters
user (
Optional
[str
]) – User/Email for login. If not specified, a prompt will ask for itpassword (
Optional
[str
]) – Password for login. If not specified, a password prompt will ask for itbaseurl (
Optional
[str
]) – Base url of the studio instance used for this call. IfNone
, the environment variableDO_BASEURL
will be used. IfDO_BASEURL
is not defined, the standard base-url will be used.
- Return type
str
- Returns
The product key for the user
- Raises
LoginException if the login failed –
Examples:
>>> import autonlu >>> product_key = autonlu.get_product_key(user="admin")
- autonlu.list_models(organization=None, key=None, baseurl=None, retries=10)¶
Returns a list of all available models as tuples (model name, display name, model id, retries: int = 10)
- Parameters
organization (
Optional
[str
]) – If given, returned list will contain all models available und the specified organization. Otherwise returns the list of models available to the user.key (
Optional
[str
]) – Token to authenticate a user. If not given, a token will be looked up in the environment variableDO_PRODUCT_KEY
.baseurl (
Optional
[str
]) – Base url of the studio instance used for this call. IfNone
, the environment variableDO_BASEURL
will be used. IfDO_BASEURL
is not defined, the standard base-url will be used.retries (
int
) – Number of times to retry the command before giving up
- Returns
Returns the list of models that are available for download by a user or for a specified organization. For each model a tuple of the format (model name, display name, model id)
Examples:
Getting list of models for user authenticated by
DO_PRODUCT_KEY
>>> autonlu.list_models() [('DeepOpinion/sights-activities_absa_en', 'Sights & Activities', 77), ('DeepOpinion/alpine-hotels_absa_en', 'Alpine Hotels - EN', 76), ('DeepOpinion/alpine-hotels_absa_de', 'Alpine Hotels - DE', 75), ('DeepOpinion/employee-experience_absa_en', 'Employee Experience', 73), ... ('DeepOpinion/automotive_absa_en', 'Automotive', 72), ('DeepOpinion/conversational-demo_absa_en', 'Conversational - Demo', 71), ('DeepOpinion/vacuum-cleaners_absa_en', 'Vacuum Cleaners', 70)]
Getting list of models for a specified organization
>>> models = list_models(organization = 2)
Getting list of models for a specified organization from a locally running Studio instance
>>> models = list_models(organization = 2, baseurl="http://192.168.0.23")
- autonlu.get_model_by_id(id, organization=None, key=None, baseurl=None, retries=10)¶
Downloads a model with a given model ID and returns the path to where the model has been downloaded to
- Parameters
id (
int
) – ID of the model to downloadorganization (
Optional
[int
]) – Name of organization (if any) to usekey (
Optional
[str
]) – Token to authenticate a user. If not given, a token will be looked up in the environment variableDO_PRODUCT_KEY
.baseurl (
Optional
[str
]) – Base url of the studio instance used for this call. IfNone
, the environment variableDO_BASEURL
will be used. IfDO_BASEURL
is not defined, the standard base-url will be used.retries (
int
) – Number of times to try the operation if it fails
- Returns
Path to where the model was downloaded
Examples:
>>> modelpath = autonlu.get_model_by_id(51) >>> model = autonlu.Model(modelpath)
- autonlu.list_projects(baseurl=None, key=None)¶
Returns a list of project names and project ids
- Parameters
key – Token to authenticate a user. If not given, a token will be looked up in the environment variable
DO_PRODUCT_KEY
.baseurl – Base url of the studio instance used for this call. If
None
, the environment variableDO_BASEURL
will be used. IfDO_BASEURL
is not defined, the standard base-url will be used.
- Returns
List of
(project name, project id)
tuples
Example
>>> autonlu.list_projects() ('Hotel', 1), ('BuzzValue', 16), ('Hotel Arabic', 48)]
- autonlu.list_annotations(project_id, key=None, baseurl=None)¶
Returns a list of all annotations of a project
- Parameters
project_id – ID of the project to get annotations from
key – Token to authenticate a user. If not given, a token will be looked up in the environment variable
DO_PRODUCT_KEY
.baseurl – Base url of the studio instance used for this call. If
None
, the environment variableDO_BASEURL
will be used. IfDO_BASEURL
is not defined, the standard base-url will be used.
- Returns
A list containing
(annotation_id, annotation_name)
tuples
Example:
>>> autonlu.list_annotations(project_id=1) [(32, 'test_annotation'), (1, 'hotel_nano_annotation.json')]
- autonlu.get_annotations(project_id, exclude=None, key=None, baseurl=None)¶
Retrieves all the annotations (labeled data) for a project from Studio
- Parameters
project_id – ID of the project to get annotations from
exclude – A list of annotation ids that should be excluded from the download
key – Token to authenticate a user. If not given, a token will be looked up in the environment variable
DO_PRODUCT_KEY
.baseurl – Base url of the studio instance used for this call. If
None
, the environment variableDO_BASEURL
will be used. IfDO_BASEURL
is not defined, the standard base-url will be used.
- Returns
A tuple
(segments, classlabels, standard_label)
wheresegments
is a list of strings,classlabels
is a list of list of (class, label) tuples, andstandard_label
is a string
- autonlu.studio.upload_model(modelpath, name, display_name=None, short_description='', long_description='', language='en', key=None, baseurl=None, verbose=False)¶
Uploads a model that is saved in a specified path with given parameters
- Parameters
modelpath (
str
) – Path of the model you want to upload to Studioname (
str
) – The internal name that should be used for the model in Studio (e.g. this is the name you can use to later download the model from Studio again). Has to be unique. If a model with the same name already exists on Studio, anModelNameExists
exception will be thrown.display_name (
Optional
[str
]) – The name which should be displayed for this model in Studio. Does not have to be uniqueshort_description (
str
) – The description that is shown below the model name in the model list. If empty, the content oflong_description
will be used.long_description (
str
) – The description that is shown when the model is opened. If empty, the content ofshort_description
will be used.language (
str
) – A language identifier (e.g."en"
,"de"
). https://en.wikipedia.org/wiki/ISO_639-1key (
Optional
[str
]) – Token to authenticate a user. If not given, a token will be looked up in the environment variableDO_PRODUCT_KEY
.baseurl (
Optional
[str
]) – Base url of the studio instance used for this call. IfNone
, the environment variableDO_BASEURL
will be used. IfDO_BASEURL
is not defined, the standard base-url will be used.verbose (
bool
) – IfTrue
, some information is printed when compressing the model is finished etc.
- Raises
ModelNameExists if the chosen name is already used in Studio –