Skip to content

Python SDK - Metrics

Track metric

askanna.track_metric

from askanna import track_metric

track_metric(name, value, label)

Parameters

Name Type Required Description
name String Yes Name of the value you want to track
value
  • String
  • Integer
  • Float/numeric
  • Date
  • Time
  • Datetime (ISO8601)
  • Boolean
  • Tag
  • Dictionary
Yes Value you want to track. See the list of types for formats we support in AskAnna.
label
  • List
  • Dictionary
No Labels you want to add to the tracked metric. Labels can only contain a name or a name & value.

Output

No output. Track metric will temporarely store metrics in a local JSON file. When you run the script locally without a run SUUID set, AskAnna will display the location of the local file.

askanna.track_metrics

from askanna import track_metrics

track_metrics(metrics, label)

Parameters

Name Type Required Description
metrics Dictionary Yes Dictionary with metrics (name & values) you want to store. See track_metric for value types that we support.
label
  • List
  • Dictionary
No Labels you want to add to the tracked metric. Labels can only contain a name or a name & value.

Output

No output. Track metric will temporarely store metrics in a local JSON file. When you run the script locally without a run SUUID set, AskAnna will display the location of the local file.

Get metrics

askanna.metrics.get

import askanna

run_metrics = askanna.metrics.get(run=...)

# or with a filter:
run_metrics = askanna.metrics.get(run=...).filter(name=....)

Parameters

Name Type Required Description
run List No Run SUUID of the run from which you want to get the metrics
job String No Job SUUID of the job from which you want to get the metrics

Output

A list with Dataclass: Metric

On this list it's possible to get a single object, or to filter multiple objects:

run_metrics.get(name=...) # get a single object

run_metrics.filter(name=...) # filter multiple objects