Starting example
Example 1: Simple annotation¶
This is a simple example to showcase the general usage of lmrtfy. It can be found
in examples/starting_example/example1.py
.
The two core concepts are the variable
and result
functions which annotate the inputs and
outputs of the script. They are needed to create the profile which is used to create the API.
example1.py | |
---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
|
- The functions need to be imported from the lmrtfy library
- The variable
x
has the local value5
and can be between 1 and 10. - You can have numpy arrays as inputs
- Lists and dictionaries work, too!
- Results are similar to variables. They have a name and an expression that they will become.
Run python examples/starting/example1.py
to create the profile needed for the deployment.
Deployment¶
To deploy the script run lmrtfy deploy examples/starting/example1.py --local
Call example1
from code¶
Now you can simply call catalog.example1()
with the correct arguments, and you are good to go:
call_example1.py | |
---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
|
<your_namespace>
is your private namespace on LMRTFY, which is typically your nickname. Available namespaces are shown when importingcatalog
or when callingcatalog.update()
.
if job:
is currently required to ensure that you actually got a job object back from the function
which would not be the case if the submission failed.
Calling example1
from the CLI¶
Note
We encourage you to use code to submit jobs and get results.
During the deployment you should have received a seven letter profile_id
:
Profile_id to be used for requests: CgHUejl
We need the profile_id
to submit a job from the CLI:
lmrtfy submit CgHUejL examples/starting/example1.json
If the JSON file has the correct inputs, in a valid range with correct units you will see that the job submission was successful. You will receive a ten-letter job ID.
INFO Job submission successful.
INFO Job-id: HgaUbcTFah
With this job_id
you can now get the job results:
lmrtfy fetch HgaUbcTFah .
That's all that is to it. Happy Hacking!