1.1 Hello World
Preparation
In this tutorial, we'll use poetry
to manage our project dependencies. If you don't have poetry
installed, you can install it by following the instructions here.
Creating A Project
You'll start by creating a new python project. You can name it whatever you like; for this tutorial, we'll call it awel-tutorial
.
We suggest making a project directory in your home directory, but you can put it wherever you like.
Open a terminal and run the following commands to make a project directory and an AWEL tutorial directory:
For Linux, macOS, or PowerShell, enter this:
mkdir -p ~/projects
cd ~/projects
Then, run the following commands to create a new project and change to the new directory:
poetry new awel-tutorial
cd awel-tutorial
The tree of the project should look like this:
awel-tutorial
├── README.md
├── awel_tutorial
│ └── __init__.py
├── pyproject.toml
└── tests
└── __init__.py
Adding DB-GPT Dependency
poetry add "dbgpt>=0.5.1"
First Hello World
Next, you'll create a simple DAG that prints "Hello, world" to the console.
Now create a new file called first_hello_world.py
in the awel_tutorial
directory and add the following code:
from dbgpt.core.awel import DAG, MapOperator
with DAG("awel_hello_world") as dag:
task = MapOperator(map_function=lambda x: print(f"Hello, {x}!"))
task._blocking_call(call_data="world")
Now, the tree of the project should look like this:
awel-tutorial
├── README.md
├── awel_tutorial
│ ├── __init__.py
│ └── first_hello_world.py
├── poetry.lock
├── pyproject.toml
└── tests
└── __init__.py