Quickstart using CLI
A quickstart guide to run GlassFlow, create your first pipeline using CLI, produce and consume data.
Prerequisites
To complete the Quickstart you'll need the following:
Python is installed on your machine.
Download and Install Pip to manage project packages.
Install GlassFlow CLI
Install the GlassFlow CLI on macOS using the Homebrew:
You can also install the CLI using other installation options on Linux/Windows.
Create a GlassFlow account
To initiate the signup process via the GlassFlow CLI, run the following command:
Follow the sign-up steps, after successfully creating an account, you are ready to create a new pipeline.
Creating Your First Pipeline
Step 1: Setup Project
Start by creating a dedicated project folder. Create a directory for this project named glassflow-playground
, where you will place all the necessary files.
Step 2: Install GlassFlow SDK
Install the GlassFlow Python SDK using pip
.
Optional: Create a virtual environment before installing Python dependencies. Run the following command:
python -m venv .venv && source .venv/bin/activate
Step 3: Create a Transformation Function
Create a new file transform.py
and write a short Python code that transforms incoming data. The function you write will parse the incoming JSON data, convert product quantities based on unit measurements, and categorize product items.
Note that the handler function is mandatory to implement in your code. Without it, the running transformation function will not be successful.
You can also import
other Python dependencies (packages) in the transformation function. See supported libraries with GlassFlow.
Step 4: Create a New Space
Create a new space with <space_name>
where one or more pipelines are contained.
After creating the space successfully, you will get a SpaceID in the terminal.
Step 5: Create a Pipeline
Run the following command in a terminal to create your pipeline inside the space using the CLI tool.
After running the command, it returns a new Pipeline ID with its Access Token and the pipeline becomes active immediately. Note down the Pipeline ID and Access Token. You'll set them as environment variables in the upcoming section.
Important: Now the transformation function is deployed and running on GlassFlow’s Serverless Execution Engine in the cloud, and you do not need to configure or maintain any infrastructure on your side.
Step 6: Get Your Pipeline Credentials (Optional)
You can also retrieve pipeline credentials with easy steps. Run the following command to retrieve Pipeline ID(Identifier):
You will get a message on the terminal with the Pipeline ID and Space ID:
To get the pipeline access token, run the List Access Tokens CLI command:
Step 7: Set environment variables
Set environment variables with your actual GlassFlow pipeline credentials such as PIPELINE_ID
and PIPELINE_ACCESS_TOKEN:
After running these commands, the environment variables PIPELINE_ID
and PIPELINE_ACCESS_TOKEN
will be available to your application allowing it to connect to your GlassFlow pipeline from the client SDK.
Sending Data to Your Pipeline
Now you can start sending data to the pipeline. GlassFlow will automatically run your transformation function on each event entering the pipeline and make your transformed data available in milliseconds.
Create a new Python file in your project root directory called producer.py
. Write a script to read auto-generated inventory data and send it to the GlassFlow pipeline. Copy and paste the following code to producer.py
file:
Run the above Python script with the following command in your terminal:
When you run the above script, on every event that enters the pipeline, GlassFlow will invoke the transformation function that you have defined in the inventorymanagement
. In this case, it will run the transform.py
file and transform every raw data you send to the pipeline.
Consuming Data from Your Pipeline
Create a new Python file called consumer.py
. The consumer is responsible for pulling transformed data from the pipeline. It continuously checks for new data, processes it as needed, and acts upon the transformed information. Copy and paste the following code to consumer.py
the file:
Run the above Python script consumer.py
in a separate terminal window to see the output side-by-side:
Now you activated the consumer side of the pipeline. This consumer.py
script retrieves the processed data from the pipeline in real-time and you will see the results of data transformation written to a new local file called (supplier_inventory.txt
).
You can watch the new transformations by running the following command on a different terminal window
Congratulations! You've set up a real-time inventory management system pipeline using GlassFlow.
Conclusion
In this Quickstart you've learned the following:
How to install GlassFlow and set up a new project.
How to create a data pipeline using the GlassFlow CLI.
How to implement transform function and process data in real-time.
How to publish data into the pipeline.
How to consume data from the pipeline.
Next
Explore the tutorials section to help you master real-time data streaming and processing with GlassFlow.
Last updated