Quick start
This is our quick start guide. Everything you need to know to get started is here.
Installation¶
You can install the lmrtfy package just like any other package:
$ pip install lmrtfy
If you use conda you need to install pip
in your conda environment before you can use LMRTFY. This
is likely necessary on Windows.
$ conda install pip
$ pip install lmrtfy
Sign-Up¶
To make full use of LMRTFY you need to sign up with us with lmrtfy login
.
You can sign up with GitHub to streamline the process.
Calling your first remote function¶
Calling a function that is available in the cloud is as easy as calling a native function.
IPython listing - Best way to call jobs interactively | |
---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
|
- If you want to know more about namespaces go here.
- This calls the function
free_fall_lmrtfy
in the LMRTFY namespaceexample
. The function is executed on a remote resource that has been provided by us. - The job is created and that status is
ACCEPTED
. Sometimes the computation is so quick that it immediately returnsRESULTS_READY
. job.ready
checks if the results are computed and ready to be fetched withjob.results
job.results
gets the results from LMRTFY as JSON:{ "<variable name>": <value>, ... }
As you can see calling the function free_fall_lmrtfy
looks just like calling any other function in Python;
however, it is actually executed on a remote server, in this case on our own server as we provide the
example.
Each call to a deployed function returns a Job
object if the submission was successful. If an error
occurred None
is returned. This way we can check if the submission was successful or not.
If you get an error here, please let us know via hello@lmrt.fyi or open an issue.
To get the results from the computation we can simply call job.results
. Depending on the size of the
results this call will take a while. In the example, this call should at most take a few seconds.
Deploying your first function¶
Deploying your own function is really easy, too.
Let's say you want to calculate how fast a falling object will be after \(x\) seconds.
The code which can be used with LMRTFY is really simple:
free_fall_lmrtfy.py | |
---|---|
1 2 3 4 5 6 7 8 9 |
|
variable
andresult
are the imports that are needed to annotate your code to make it work with LMRTFY.variable
annotates any inputs of your script.result
annotates a result of script. A script can have multiple results.
The highlighted lines have been added or changed to let LMRTFY know about the structure of the script.
Before we can deploy the function we need to run it through the Python interpreter once to create the annotation profile.
$ python free_fall_lmrtfy.py
To deploy this function on your laptop you simply run
$ lmrtfy deploy free_fall_lmrtfy.py --local
catatlog.<user_namespace>.free_fall_lmrtfy
and starts a runner on your laptop.
Nobody but you can call the function unless you share it with others.
If no runner is deployed an error will be returned.