Python is an easy-to-use programming language, which is often used for data science and scientific computations. This guide explains how you can run Python scripts on Nerdalize without any knowledge of Docker.
You can simply upload a folder with your Python scripts, data files and, if you have any Python dependencies, a
requirements.txt. If you don't have a script at hand, we have a fun example script, that calculates how much CO2 Nerdalize can save the world.
Running your Python workload on Nerdalize
Make sure you’ve set up Nerd, our CLI.
Upload the folder containing your Python scripts and data files.
This folder may include a
requirements.txtfile describing your Python dependencies.
$ nerd dataset upload <path-to-folder> 105.30 MiB / 194.31 MiB [=======>---] 51% 4s Uploaded dataset with ID <dataset-id>
Don’t have a Python script at hand? Download our CO2 calculator and unzip it.
If you’re using Python 3:
Use this for our example script.
$ nerd workload start nerdalize/pythonapp:v3 --input-dataset <dataset-id> Workload created with ID: <workload-id>
If you’re using Python 2:
$ nerd workload start nerdalize/pythonapp:v2 --input-dataset <dataset-id> Workload created with ID: <workload-id>
Execute the Python script.
Any files it writes to the
/outputfolder can later be downloaded as an output dataset.
$ nerd task create <workload-id> -- <main-python-file> <python-arguments> Started task with ID: <task-id>
Using our example script? Use the following command to calculate the CO2 savings if Nerdalize equips 5 households with a CloudBox:
$ nerd task create <workload-id> -- co2_calc.py 5 Started task with ID: <task-id>
You can run computations simultaneously with different environment variables and arguments. Take a look at the quickstart to see how that works.
Review the logs.
List the workload’s workers.
$ nerd workload describe <workload-id> Workload Details: ID: <workload-id> Image: nerdalize/pythonapp:v3 Input: Created: 2 minutes ago Workers: <worker-id> (Running)
Request the log output for a worker.
$ nerd worker logs <workload-id> <worker-id>
Check on the status of your tasks.
$ nerd task list <workload-id> TASK ID CMD OUTPUT ID STATUS CREATED <task-id>  <output-id> SUCCESS 22 minutes ago
When your task’s status is
SUCCESSit’s finished and you can continue to download the output.
Download the collection of output files.
$ nerd dataset download <output-id> <target-dir>
$ nerd workload stop <workload-id>
You’ve run Python on Nerdalize. Awesome!
You can run another Python computation or use your own Docker image.
Have any questions about using Nerdalize compute?