Context configuration
You can change your Python tracking context configuration by using 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 environment variables or inline configuration.
Defining environment variables
Define 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, which applies only to
run_name,job_name,project_name.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, which applies to all
parameters.
from dbnd import dbnd_tracking with dbnd_tracking(run_name="example_run_name", job_name="example_job_name", project_name="example_project"): pass
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",
}
}
):
passAdding 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.
from dbnd import dbnd_tracking
with dbnd_tracking
(conf={
"core": {
"databand_url": "<databand_url>",
"databand_access_token":"<access_token>",
}
}
):
passEnabling code collection
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
}
}
)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 verbose mode
Enable 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.
from dbnd import set_verbose
set_verbose()export DBND__VERBOSE=True