Context configuration
You can change your Python tracking context configuration by using the environment parameters or implicit configuration.
Tracking parameters
When you track your Python script, you can set a custom source name, a job, a project, a username, and a run name in the script to identify a run in the Databand UI later on. As a result, you can search and filter runs by using their custom names for sources, jobs, or projects. Moreover, you can identify a run in the UI through the names of the users who triggered them, or the run's name. You can check the run name by going to the Advanced details section of the Run overview tab.
You can set the tracking parameters by defining the environment variables or inline configuration.
Defining the environment variables
Define the environment variables to set the tracking parameters for a custom source name, a job, a project, a username, and a run name:
export DBND__RUN_INFO__USER="example_user"
export DBND__RUN_INFO__NAME="example_run_name"
export DBND__TRACKING__SOURCE="example_source"
export DBND__TRACKING__JOB="example_job_name"
export DBND__TRACKING__PROJECT="example_project"
Inline configuration
Use inline configuration to set the parameters.
The full signature of the function is as follows:
def dbnd_tracking(
job_name=None, run_name=None, project_name=None, conf=None
)
Depending on the type of arguments, you can configure the parameters in different ways:
- Passing values explicitly
It applies torun_name
,job_name
,project_name
, only.
from dbnd import dbnd_tracking
with dbnd_tracking(run_name="example_run_name", job_name="example_job_name", project_name="example_project"):
pass
- Using a dictionary object
It applies to all the parameters.
from dbnd import dbnd_tracking
with dbnd_tracking(
conf={
"run_info": {
"user": "example_user",
"name": "example_run_name"
},
"tracking": {
"source": "example_source",
"job": "example_job_name",
"project": "example_project"
}
}
):
pass
You can also use a combination of explicit values and a dictionary:
from dbnd import dbnd_tracking
with dbnd_tracking(job_name="example_job_name", project_name="example_project",
conf={
"run_info": {
"user": "example_user",
},
"tracking": {
"source": "example_source",
}
}
):
pass
Adding the authentication credentials
You can also change the authentication credentials of the Databand connection.
Add the SDK configuration parameters to the tracking context by adding configuration with the conf
parameter of the dbnd_tracking
function.
Don't embed credentials into your code. For more information on providing credentials, see Connecting to Databand service.
from dbnd import dbnd_tracking
with dbnd_tracking
(conf={
"core": {
"databand_url": "<databand_url>",
"databand_access_token":"<access_token>",
}
}
):
pass
Enabling code collection
You can also enable code collection as part of dbnd_tracking
by providing the following code snippet:
with dbnd_tracking(
conf={
"core": {
"databand_url": "your URL",
"databand_access_token": "your token"
},
"tracking": {
"track_source_code": True
}
}
)
Additionally, the conf
object can contain the logging configuration paramteres, for example:
"log": {
"preview_head_bytes": 8192,
"preview_tail_bytes": 8192
},
For more information on Python SDK configuration, see Python SDK configuration.
Enabling the verbose mode
Enable the verbose mode in the script to gain insight into the ongoing debugging process in Databand. It can be helpful in debugging connection, authentication and configuration problems.
To enable the verbose mode, you can add the following lines to the script:
from dbnd import set_verbose
set_verbose()
Enabling the verbose mode from CLI
You can also enable it from CLI by running the following command before you run your script:
export DBND__VERBOSE=True