Running Hello World#

This tutorial explains how to run a simple “Hello World” workflow in Dioptra using the Guided User Interface (GUI). You will learn the essential lifecycle of a Dioptra task: writing code, creating a plugin, defining an entrypoint, and running a job.

Prerequisites#

Before starting, ensure you have installed Dioptra and completed the setup step of this tutorial.

Hello World Workflow#

Our goal is to run a Python function that prints a message to the Dioptra logs.

Step 1: Prepare Python Code#

First, we need the Python code that defines our task. We will use the structlog library to ensure our message appears in the Dioptra job dashboard.

hello_world.py

import structlog
from dioptra import pyplugs

logger = structlog.get_logger(__name__)

@pyplugs.register
def hello_world():
    logger.info("Hello, World! Welcome to Dioptra.")

Copy the code above (you will paste it into the GUI in the next step).

Note: The code uses the @pyplugs.register decorator to turn a standard function into a Plugin Function Task. Learn More.

Step 2: Create the Plugin#

We must create a container for our code and register the task in the system.

  1. In the GUI, navigate to the Plugins tab.

  2. Click Create Plugin.

  3. Enter the name hello_world_plugin and add a short description. Click Submit.

Screenshot of the plugin creation / registration modal

Creating the Hello World Plugin Container#

  1. In the plugin list, click the row corresponding to the Hello World Plugin you just created to go to the Plugin Files table.

Screenshot of the plugin creation / registration modal

The created Hello World Plugin container#

  1. In the Plugin Files table, click Create to add a new file.

  2. Name the file plugin_1.py, add a description, and paste the code from step 1 into the editor.

Register the Task

  1. In the Task Form (on the right side of the editor), register the function:

    • Task Name: hello_world (Must match the Python function name exactly).

    • Input/Output Parameters: Leave blank - Our function has no inputs and returns no outputs.

Screenshot of the task registration

Registering the Python function as a Plugin Task#

  1. Click Submit File.

Screenshot of the finalized hello world plugin file with task registered

The Plugin file with our registered hello world task#

Step 3: Create an Entrypoint#

Entrypoints define the workflow (Task Graph) that sequences our tasks. Our workflow is one with a single task only.

  1. Navigate to the Entrypoints tab.

  2. Click Create Entrypoint.

  3. Name it hello_world_entrypoint.

Screenshot of entrypoint creation metadata
  1. In the Task Plugins window, select the hello_world_plugin we created in Step 2.

  2. In the Task Graph YAML editor, paste the following YAML:

Entrypoint Task Graph

hello_world_step: # Task name
   task: hello_world # One of our registered tasks
  1. Click Validate Inputs (it should pass as there are no parameters).

Screenshot of the Entrypoint creation screen showing the YAML editor.

Defining the workflow structure in the Entrypoint editor.#

  1. Click Submit Entrypoint.

Step 4: Create Experiment & Job#

To execute the entrypoint, we must place it inside an Experiment and run it as a Job.

  1. Navigate to the Experiments tab and click Create Experiment.

  2. Name it hello_world_experiment.

  3. In the Entrypoint dropdown, select hello_world_entrypoint.

Screenshot of the Experiment creation process

Creating the hello world experiment#

  1. Click Submit Experiment.

  2. Once the experiment is created, click on the experiment - the Experiment’s Job page should appear.

  3. In the jobs table, click Create.

  4. Select the hello_world_entrypoint.

  5. Select the queue you created in the previous tutorial (tensorflow-cpu).

  6. Click Submit Job.

Screenshot of the Job submission modal.

Submitting the job to the queue.#

Step 5: Inspect Logs#

The job will transition from Queued to Finished. We can verify the code ran by checking the logs.

  1. In the Jobs tab, click the job you just ran.

  2. Navigate to the Logs tab within the job details.

Screenshot of the Job Logs tab showing the Hello World message.

Viewing the execution logs.#

You should see the following message generated by hello_world_plugin.plugin:

Job Log Output

[info     ] Hello, World! Welcome to Dioptra. [hello_world_plugin.plugin]

Note

If the Job never transitions out of the “Queued” state, there may be an issue with your Queue / Worker configuration. The tensorflow-cpu Queue is meant to directly communicate with the tensorflow-cpu worker, one of the default workers available as a pre-built container. The name of the queue must exactly match the Worker configuration file (Learn More).

Conclusion#

You have successfully run your first Dioptra job! You wrote a Python function, wrapped it in a Plugin, sequenced it in an Entrypoint, and executed it using the GUI.

See Also#

To understand in greater depth all the components utilized in this experiment, reference Dioptra Components Explanation. You can also find syntax and file requirements in Dioptra Components Reference.

Next Steps#

Now that you have the basics down, let’s learn about more advanced functionality of Dioptra.