Quick scenario import (advanced, 10 min)
Import the retail scenario's assets and data through the Manager API with the current dhub2-examples CLI.
This tutorial is for contributors and engineers who develop scenarios or automate imports in CI/CD. To upload a ZIP file directly in Portal, use Import a hands-on scenario in one shot (5 min).
By the end of this tutorial
- Install the current
dhub2-examplesrepository and Python dependencies. - Configure Manager API authentication safely.
- Import the retail scenario's metadata, code sources, and data files.
- Verify the CLI summary and the resulting Portal resources.
1. Prepare the repository and Python environment
Run these commands in a new working directory:
git clone https://github.com/dtonic/dhub2-examples.git
cd dhub2-examples
python -m venv .venv
Activate the virtual environment:
# macOS / Linux
source .venv/bin/activate
# Windows PowerShell
.venv\Scripts\Activate.ps1
On a Korean Windows console, the CLI can raise UnicodeEncodeError when printing its ✓ status marker. Enable UTF-8 mode in the same PowerShell window first:
$env:PYTHONUTF8='1'
In Command Prompt (cmd), run set PYTHONUTF8=1 instead.
Install the two packages used by the current CLI. There is no tools/requirements.txt to install.
python -m pip install httpx python-dotenv
2. Configure the Manager API and authentication
Create .env in the dhub2-examples repository root, where the tools and scenarios directories are visible. To sign in to the production D.Hub with email and password, use:
DHUB2_API_URL=https://manager.hub.dtonic.io/api/v1
DHUB2_EMAIL=<your-email>
DHUB2_PASSWORD=<your-password>
If you already have a bearer token, use it instead of email and password:
DHUB2_API_URL=https://manager.hub.dtonic.io/api/v1
DHUB2_TOKEN=<your-token>
DHUB2_API_URL is the Manager API base URL, including /api/v1, not the Portal URL. The .env file contains credentials, so never commit it to Git.
3. Import the scenario
Start with a dry run to inspect the files and execution order without making API calls:
python tools/import.py scenarios/retail_inventory_intelligence --dry-run
If the expected items appear, run the actual import:
python tools/import.py scenarios/retail_inventory_intelligence
The CLI performs the following work in dependency order:
- 1 collection
- 3 datasets and 2 Code items
- 4 ontology Entities and 3 Relations
- 2 Pipelines and 1 Dashboard
- 1 Agent Tool and 1 Agent
- 2 Code source uploads and 3 Parquet data uploads
In a clean environment, the current final summary is:
Created : 23
Skipped : 0
Failed : 0
The count of 23 includes 18 resources, two Code source uploads, and three data uploads.
4. Verify the result in Portal
Open the retail_inventory_intelligence collection in Portal and verify:
- 3 datasets:
retail_inventory,competitor_prices, andupdate_competitor_price - 2 Code items and 2 Pipelines
- the
inventory_overviewDashboard - 4 ontology Entities and 3 Relations
The Data tabs of retail_inventory, competitor_prices, and update_competitor_price contain rows immediately after import. update_competitor_price is not created by a later Pipeline run; the importer creates the dataset and uploads its data as part of this scenario import. Open retail-assistant from the Agents list and confirm that its detail page links the ontology_graph_query tool in the same collection scope.
Continue with Retail Inventory Intelligence to use the imported resources.