Examples: query, "exact match", wildcard*, wild?ard, wild*rd
Fuzzy search: cake~ (finds cakes, bake)
Term boost: "red velvet"^4, chocolate^2
Field grouping: tags:(+work -"fun-stuff")
Escaping: Escape characters +-&|!(){}[]^"~*?:\ with \, e.g. \+
Range search: properties.timestamp:[1587729413488 TO *] (inclusive), properties.title:{A TO Z}(excluding A and Z)
Combinations: chocolate AND vanilla, chocolate OR vanilla, (chocolate OR vanilla) NOT "vanilla pudding"
Field search: properties.title:"The Title" AND text
Answered
Hello! I'Ve Been Trying To Use Clearml For The First Time, But I Cannot Seem To Run The First Serving Model. First, I Run The Following In Powershell: >>> Clearml-Serving Create --Name "June Test" Log: Clearml-Serving - Cli For Launching Clearml Serving

Hello!

I've been trying to use ClearML for the first time, but I cannot seem to run the first serving model.

First, I run the following in Powershell:

clearml-serving create --name "june test"
log:
clearml-serving - CLI for launching ClearML serving engine
New Serving Service created: id=56f696a89cc94909ade484adfaecda0c

Second, I ran the code below in Python:
from sklearn.linear_model import LogisticRegression
from sklearn.datasets import make_blobs
from joblib import dump
from clearml import Task

task = Task.init(project_name="serving examples", task_name="train sklearn model in June", output_uri=' None ')

generate 2d classification dataset

X, y = make_blobs(n_samples=100, centers=2, n_features=2, random_state=1)

fit final model

model = LogisticRegression()
model.fit(X, y)

dump(model, filename="sklearn-model.pkl", compress=9)

Finally, in Powershell:

clearml-serving --id 56f696a89cc94909ade484adfaecda0c model add --engine sklearn --endpoint "test_model_sklearn_june" --name "train sklearn model in June - sklearn-model" --project "serving examples"
log:
clearml-serving - CLI for launching ClearML serving engine
Serving service Task 56f696a89cc94909ade484adfaecda0c, Adding Model endpoint '/test_model_sklearn_june/'
Info: syncing model endpoint configuration, state hash=d3290336c62c7fb0bc8eb4046b60bc7f
Updating serving service

Now, I try to get the model to do inference and I get 422 error.
I tried from Python and then move to use None but it still doesn't work...
I'm Attaching an image that above you can see the serve instance with the model endpoint in the UI and below the docs and what it gives me for the call.

Help please... 🙏
image

  
  
Posted 2 months ago
Votes Newest

Answers 14


Do you see any errors in the serving containers? Also what response do you get when you try a curl command from the machine itself locally ( None ... )
None

    curl -X POST "
" -H "accept: application/json" -H "Content-Type: application/json" -d '{"x0": 1, "x1": 2}'
  
  
Posted 2 months ago

Hi @<1523701070390366208:profile|CostlyOstrich36>
Sorry for the delayed response.

No errors in the serving containers.
I did follow the link you've shared before posting. I ran the following:
curl.exe -X POST " None " -H "accept: application/json" -H "Content-Type: application/json" -d '{"x0": 1, "x1": 2}'
(note that I'm using port 8082, since 8080 is already taken by ClearML Server on this VM).
and got the following response:

{"detail":[{"type":"json_invalid","loc":["body",1],"msg":"JSON decode error","input":{},"ctx":{"error":"Expecting property name enclosed in double quotes"}}]}

So I fixed it by changing:
-d '{"x0": 1, "x1": 2}'
to:
'{\"x0\": 1, \"x1\": 2}'
And I'm back to the original issue I had (in the image), with the log:

{"detail":"Error [<class 'ValueError'>] processing request: Expected 2D array, got scalar array instead:\narray={'x0': 1, 'x1': 2}.\nReshape your data either using array.reshape(-1, 1) if you
r data has a single feature or array.reshape(1, -1) if it contains a single sample."}

Am I the only one encountering it? 😞

  
  
Posted 2 months ago

Can you add such an attempt and the outputs please?

  
  
Posted 2 months ago

And that is the bottom of the screenshot that I've shared (light green background)

  
  
Posted 2 months ago

Hi @<1838387863251587072:profile|JealousCrocodile85> , can you please add the specific commands you ran and the full console output of this?

  
  
Posted 2 months ago

So, I went to the link

in order to use it like Postman. Testing the API without using Python. It was ChatGPT that directed me there, and it is kind of a nice way to validate the API

I would ignore anything that ChatGPT says about ClearML (and most other things too)

  
  
Posted 2 months ago

How did you try to access the endpoint? Via curl?

  
  
Posted 2 months ago

I'm mostly with agreement with you on that 🙂
ClearML has a great documentation. But now that I've tried it all, I gave ChatGPT a shot. It got me introduced to the /docs#/, which is kind of a nice way to test the API.
But the issue still remains and I cannot finish my POC 😞

  
  
Posted 2 months ago

Sorry for the trouble, you are right. Now it looks much better.
Please let me know if it still needs explanation or information

  
  
Posted 2 months ago

Thanks! I'm curious, why do you have /docs#/ in the url

  
  
Posted 2 months ago

Its a bit confusing, please add the full list of action you took + whatever the console printed.

Preferably using the following format for logs

This is a very convenient way to post logs 
  
  
Posted 2 months ago

Hi John,
thanks for answering.
Maybe I missed anything in the description?
I wrote the commands and the log (console output)

  
  
Posted 2 months ago

In Python, I ran the following with many variation of the data:

import requests
from typing import Any
import numpy as np
import json

url = "
"

raw_input = json.dumps([1, 2])  # This becomes a JSON string like "[1, 2]"

response = requests.post(
    url=url,
    headers={
        'accept': 'application/json',
        'Content-Type': 'application/json'
    },
    json=raw_input
)

print(response.status_code, response.json())

And always got:

422 {'detail': "Error [<class 'ValueError'>] processing request: Expected 2D array, got scalar array instead:\narray={'x0': 1, 'x1': 2}.\nReshape your data either using array.reshape(-1, 1) if your data has a single feature or array.reshape(1, -1) if it contains a single sample."}

or:

422 {'detail': [{'type': 'bytes_type', 'loc': ['body', 'bytes'], 'msg': 'Input should be a valid bytes', 'input': [{'x0': 1, 'x1': 2}], 'url': '
'}, {'type': 'dict_type', 'loc': ['body', 'dict[any,any]'], 'msg': 'Input should be a valid dictionary', 'input': [{'x0': 1, 'x1': 2}], 'url': '
  
  
Posted 2 months ago

So, I went to the link None in order to use it like Postman. Testing the API without using Python. It was ChatGPT that directed me there, and it is kind of a nice way to validate the API

  
  
Posted 2 months ago
358 Views
14 Answers
2 months ago
2 months ago
Tags