Checkmark=facebooklinklinkedinOngoing indicator +Left-facing arrowRight-facing arrowCheckmarkDown-pointing chevronLeft-pointing chevronRight-pointing chevrontwitter



2.7.14, 3.6.3

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

  1. Make sure you’ve set up Nerd, our CLI.

  2. Upload the folder containing your Python scripts and data files.

    This folder may include a requirements.txt file 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.

  3. Start Python.

    • 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>
  4. Execute the Python script.

    Any files it writes to the /output folder 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> -- 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.

  5. Review the logs.

    1. List the workload’s workers.

      $ nerd workload describe <workload-id>
      Workload Details:
      ID:              <workload-id>
      Image:           nerdalize/pythonapp:v3
      Created:         2 minutes ago
      Workers:         <worker-id> (Running)
    2. Request the log output for a worker.

      $ nerd worker logs <workload-id> <worker-id>
  6. 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 SUCCESS it’s finished and you can continue to download the output.

  7. Download the collection of output files.

    $ nerd dataset download <output-id> <target-dir>
  8. Stop Python.

    $ 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?

Get in touch