Skip to main content

DAGWorks Tracking Adapter

Connecting with the Hosted Hamilton UI on DAGWorks takes the form of an adapter that forms a plug-in addition to the Hamilton Driver. The Hamilton driver accepts adapters, so adding in DAGWorks, allows you to run your Hamilton dataflows as usual, while also logging/tracking them with DAGWorks. You can import the adapter as follows:
import os
from dagworks import adapters
from hamilton import driver
And instantiate it:
import my_module_1, my_module_2

 dw_tracking_adapter = adapters.DAGWorksTracker(
    project_id=32, # Replace with your project ID
    api_key=os.environ["DW_API_KEY"], # Securely load your API key
    username="elijah@dagworks.io", # replace with your email
    dag_name="LTV_Model", # replace with your DAG name
    # replace with whatever metadata you want stored with your run/project version
    tags={"env" : "staging", "region" : "US"},
)

driver = (
  driver.Builder()
     .with_config({"config_item_1" : "config_value_1", "config_item_2" : "config_value_2"})
     .with_modules(my_module_1, my_module_2) # python modules with Hamilton functions
     .with_adapters(dw_tracking_adapter) # DAGWorks tracking adapter
     .build()
)
The DAGWorksTracker accepts DAGWorks-specific arguments (all keyword-only):
int Project ID from the UI. Project must already be created.
project_id=32 
Keyword-only argument.
str API key from the UI.
api_key=os.env["DW_API_KEY"] 
Keyword-only argument.
str Login from the API — full email.
username="elijah@dagworks.io"
Keyword-only argument.
str Name corresponding to the project version. See data model for more details on how this is used.
dag_name="staging"
Keyword-only argument.
Dict[str, str] Tags for locating in the UI/metadata that you can use to store information and filter runs/versions.
tags={"env" : "staging", "region" : "US"}
Keyword-only argument.
I