Skip to content

Catalog

Catalog ¶

Bases: object

The Catalog object provides an interface to deployed functions that you can run from your code.

Cloud functions are pulled into the catalog by the constructor, which happens during from lmrtfy import catalog.

If you want to retrieve newly deployed function, call catalog.update().

To run a deployed function from the catalog call catalog.<namespace>.<deployed_function>(*args, **kwargs).

Each function that has been pulled into the catalog is available via the help() command.

accept_invite(invite_id) ¶

Accept an invitation with invite_id. This only works once for each ID.

Returns True if acceptance was successful, False otherwise.

add_function_to_namespace(namespace, function) ¶

Add a function to an existing namespace.

Example:

catalog.add_function_to_namespace(catalog.<namespace>, catalog.<namespace>.<function>

create_namespace(namespace, name) ¶

Create a unique namespace that collects functions and can be shared.

Example:

catalog.create_namespace(catalog.<namespace>, "new_namespace")

Parameters:

Name Type Description Default
namespace Namespace

parent namespace

required
name str

Name of the new namespace.

required

Returns:

Type Description
bool

Returns the True on success and False in case of an error.

delete_namespace(namespace) ¶

Deletes the entire namespace. Deletion will fail if there are still functions in the namespace.

issue_deploy_token(function, token_type='deploy') ¶

This function creates a deploy token for function. It can only be used for this function.

To use the token, you need to set the environment variable LMRTFY_ACCESS_TOKEN with the token before deployment.

If you deploy with a token, you need to specify the namespace of the function with the --namespace="..." argument of lmrtfy deploy.

Returns a token with a token_id. The token_id is needed for token revocation.

issue_submit_token(function) ¶

This function creates a submit token for function. It can only be used for this function.

To use the token, you need to set the environment variable LMRTFY_ACCESS_TOKEN with the token before you submit a job:

LMRTFY_ACCESS_TOKEN="LMRTFY...." ipython
In [0]: from lmrtfy.functions import catalog

In [1]: job = catatlog.<namespace>.<function>(...)
Returns a token with a token_id. The token_id is needed for token revocation.

remove_function_from_namespace(function) ¶

Delete function from its namespace.

revoke_token(token_id) ¶

With this function you can revoke a token when you don't need it anymore. All you need is the token_id of the token which was returned to you when the token was issued.

share_namespace(namespace, recipient_email) ¶

Share a namespace with someone else by email. The invite email will be sent to recipient_email. This does not have to be the email address associated with the account of the person you want to share the namespace with.

Invites only work once.

update() ¶

Call update to update the catalog with newly deployed functions.

Job ¶

Bases: object

ready() property ¶

Returns True if the job has finished successfully and the results are ready to be fetched.

results() property ¶

Returns the results if they are ready and None otherwise. Results are returned as a dictionary:

{
    "<results_name>": result_value
}

status() property ¶

Queries the job status.

If it returns JobStatus.UNKNOWN the job is likely in failed state.