Model Pinning

Given new training data, Nyckel automatically re-trains and re-deploys your function. This ensures that the /invoke endpoint always uses the most recent model. However, there are times when this behavior is undesirable. For example, you may want to do some integration testing or other checks before switching to a new function version.

In this guide we show you how to pin your invoke endpoint to a particular model version.

NOTE: this guide relies on API calls and parameters that are in beta.

Invoke using a pinned model

To invoke using a pinned model, use the modelId query parameter. Like so:

curl -X POST \
  -H 'Authorization: Bearer <accessToken>' \
  -H 'Content-Type: application/json' \
  -d '{"data":"@<fileName>"}' \
  https://www.nyckel.com/v1/functions/<functionId>/invoke?modelId=<modelId>
import requests

url = 'https://www.nyckel.com/v1/functions/<functionId>/invoke?modelId=<modelId>'
headers = {
    'Authorization': 'Bearer ' + '<accessToken>',
}

result = requests.post(url, headers=headers, json={"data":"@<fileName>"})
print(result.text)
fetch('https://www.nyckel.com/v1/functions/<functionId>/invoke?modelId=<modelId>', {
    method: 'POST',
    headers: {
        'Authorization': 'Bearer ' + '<accessToken>',
        'Content-Type': 'application/json',
    },
    body: JSON.stringify(
        {"data":"@<fileName>"}
    )
})
.then(response => response.json())
.then(data => console.log(data));
$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, 'https://www.nyckel.com/v1/functions/<functionId>/invoke?modelId=<modelId>');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, '{"data":"@<fileName>"}');

$headers = array();
$headers[] = 'Authorization: Bearer ' . '<accessToken>';
$headers[] = 'Content-Type: application/json';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$result = curl_exec($ch);
curl_close($ch);
echo $result;

Find the modelId

To get the current modelId, use the following call to the /metrics endpoint. Note that this uses the v0.9 API version.

curl -X GET \
  -H 'Authorization: Bearer <accessToken>' \
  https://www.nyckel.com/v0.9/functions/<functionId>/metrics
import requests

url = 'https://www.nyckel.com/v0.9/functions/<functionId>/metrics'
headers = {
    'Authorization': 'Bearer ' + '<accessToken>',
}

result = requests.get(url, headers=headers)
print(result.text)
fetch('https://www.nyckel.com/v0.9/functions/<functionId>/metrics', {
    method: 'GET',
    headers: {
        'Authorization': 'Bearer ' + '<accessToken>',
    }
})
.then(response => response.json())
.then(data => console.log(data));
$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, 'https://www.nyckel.com/v0.9/functions/<functionId>/metrics');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$headers = array();
$headers[] = 'Authorization: Bearer ' . '<accessToken>';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$result = curl_exec($ch);
curl_close($ch);
echo $result;