Skip to content

Namespaces

In version 0.0.10 lrmtfy introduced namespaces to give users more flexibility and to make sharing easier.

Every user has a default namespace that corresponds to their username and a short suffix depending on the kind of login that you use.

You can see available namespace when you import the catalog. The best way to manage namespaces is to start an ipython session.

For me the output is the following:

Importing catalog
1
2
3
4
5
In [1]: from lmrtfy.functions import catalog
2022-10-11 16:57:03 [58002] INFO Available namespaces: ['examples', 'orgarten_gh']
2022-10-11 16:57:04 [58002] INFO Added function: catalog.examples.free_fall_lmrtfy
2022-10-11 16:57:05 [58002] INFO Added function: catalog.orgarten_gh.calc_compound_interest
2022-10-11 16:57:05 [58002] INFO Added function: catalog.orgarten_gh.free_fall_lmrtfy

Namespaces available to me are my private one orgarten_gh and the example namespace examples. Also shown are the available functions in my catalog.

To use a deployed function inside the namespace I would simply call

Using a function in a namespace
1
catalog.orgarten_gh.<function>(...)

If the code editor or IDE of your choice supports auto-completion, the available functions should be suggested.

Create namespacesΒΆ

You can create new namespaces inside your own user namespace:

Creating new namespaces
1
2
3
In [2]: catalog.create_namespace(catalog.orgarten_gh, "shared")
2022-10-11 18:27:27 [58002] INFO {'namespaces': ['orgarten_gh', 
'orgarten_gh/shared']}

To add a function inside a namespace you just run add_function_to_namespace.

Add a function to a namespace
1
2
In [3]: catalog.add_function_to_namespace(catalog.orgarten_gh.shared,
   ...: catalog.orgarten_gh.calc_compound_interest)

Now you can share the namespace with other users!