Run "Hello AskAnna"
The project "Hello AskAnna" is a simple demo project. The goal is to give you a quick overview of how easy it is to setup a project in AskAnna. In the "Hello AskAnna" project, we show how you can:
- create a project
- make a "Hello AskAnna" Python script
- define a job that can run the script
- push the code to AskAnna
- run the job in AskAnna
AskAnna has a powerful web interface and for many tasks you can use your browser. But sometimes it's faster to use your (local) terminal. In this example project we will show both methods. Try them both and figure out which method you like the most.
If you did not install the CLI yet, on the AskAnna CLI page you can read how to install it. Or quickly do it by running the next commands in your Python environment:
pip install askanna
And ones installed, you can log in by running:
askanna login
1. Create the project
We assume you have an AskAnna account and that you logged in. On the workspace overview, you can quickly create a project via the button Create project
. You only have to add a name, and you can create the new project. After you created the new project, you can open it.
With the AskAnna CLI you can create the project by running:
askanna create "Hello AskAnna"
This will create a project in AskAnna. Also, it will create a new local directory hello-askanna
with a file askanna.yml.
2. Hello-script
If in step 1 you created the project via the web interface, then you should now first create a local directory for your project. When you created the project via the CLI, then you should already have a directory hello-askanna
.
In this directory you can add a Python file with a script. For example:
print("Hello, AskAnna!")
Save this Python script as hello.py
.
Also for this step you can use your terminal:
echo 'print("Hello, AskAnna!")' > hello.py
3. Job configuration
If in step 1 you created the project via the AskAnna CLI, then you already have a askanna.yml
file in your local directory. When you created the project via the web interface then first add a file askanna.yml
in your local directory.
Let's define a job hello
that can run the hello-script, by adding the next lines to your askanna.yml
config file:
hello:
job:
- python hello.py
If you created the project via the CLI, then your askanna.yml
file should now contain the push-target and the definition of the job. The push-target does not have to be set, but if you want to try out the push method in the next step then you need to add the push-target to the askanna.yml
file. On the project page you can copy this info. See the green circle where you can find this information:
4. Upload or push code
4.1 Upload code
You can use the web interface of AskAnna to upload a ZIP file.
Add your local files hello.py
and askanna.yml
to a ZIP archive:
- MacOS: select the files, right click on one of them and select
Compress
- Windows: select the files, right click on one of them, go to
Send to
and then selectCompressend (zipped) folder
To upload the ZIP file, open the project in AskAnna. If you open the project in the web interface you will see something like this:
You can drag & drop the ZIP file to the dotted area, or click on browse and select the ZIP archive from there. Confirm that you want to upload the file, and AskAnna will do the rest. Probably in a second you can open the code in the web interface.
4.2 Push code
In the directory where you build the "Hello AskAnna" project, you can run the command to push your code to AskAnna:
askanna push
Now the AskAnna CLI will package your code and upload this to AskAnna. After the push (or upload) is finished, you can open your project in AskAnna. Now you should see two files. Feel free to click on a file to check the content.
5. Run the Hello-job
If you now click on the JOBS
section, you will see the job hello
:
Click on the job to open the job page. On this page you find a section Running the job
. First let's run the job via the platform. You can do this by clicking on RUN THIS JOB
:
Now you can click on OPEN THE RUN
to open the run page. On this page you can find meta information about the run. When the run finished, you can open the LOG
section and verify that AskAnna run your code:
You can also use the AskAnna CLI to run the job. If you are still in the project directory you can simply run:
askanna run hello
When you are working on a project, you probably update your scripts and want to run a job on the latest version. With the AskAnna CLI you can do this with one single command that combine step 4.2 and step 5:
askanna run hello --push
Congratulations!
You now have successfully:
- created a new project in AskAnna
- configured a job
- uploaded and/or pushed code to AskAnna
- run a job
- opened the job in the web interface