You can track runs that happened externally from the Nextmv Platform. This is useful for onboarding to Nextmv quickly without having to run your decision models in the Platform. Once a run has been tracked, you may use all the features supported by Nextmv, such as testing, and experimentation. An external run behaves just like a standard run, but it is not executed on the Nextmv Platform.
You can read more about external runs here.
Generally speaking, a run can have two final states:
succeeded
: the run was successful.failed
: the run failed.
To track a run with either of these states, you can use one of the following methods:
track_run
: tracks the run as an external run and returns the ID (run_id
) of the run. It is analogous to thenew_run
method, but it does not execute the decision model on the Platform.track_run_with_result
: does the same astrack_run
, but it also polls for the result of the run, which should be available not long after the run is submitted. This method is useful for submitting the run and getting the result in a single call. It is analogous to thenew_run_with_result
method, but it does not execute the decision model on the Platform.
Successful run
You can use the track_run_with_result
method to track, and get the result, of a run with a status of succeeded
:
The run is tracked by the Nextmv Platform and run results are polled, just as if you had executed a normal run. The main difference is that no decision model is executed on the Platform. Instead, the input and output are recorded.
Please note the following:
- The
input
can be anextmv.Input
, a simpledict[str, any]
or a plainstr
. - The
output
can be anextmv.Output
, a simpledict[str, any]
or a plainstr
. Using all the attributes ofnextmv.Output
is recommended, as it allows you to record statistics, useful for recording metrics, and assets, useful for visualizing charts. - The
status
, as mentioned previously, can besucceeded
orfailed
. - The
duration
is the time it took to run the decision model, in seconds. This is optional, but recommended.
Alternatively, you may use the track_run
method, which will just track the run and return the run_id
.
Running the code snippet above (using track_run_with_result
) will track the run and poll for the results:
Failed run
Using the same track_run_with_result
method, you can track a run with a status of failed
:
Three main differences stand out when comparing against the succeeded
example:
- The
status
is set tofailed
. - The
error
is a string that describes the error that occurred. - The
logs
are a list of strings that describe the logs that were generated during the run. Each list item is a line in the log stream.
Similarly to before, you may just use the track_run
method to track the run and get back the run_id
.
Running the code will track the run and poll for the results: