mistralai / client-python

Python client library for Mistral AI platform
Apache License 2.0
477 stars 103 forks source link

Internal Server Error on incorect integration for W&B: rather fail early ? #103

Closed didier-durand closed 4 months ago

didier-durand commented 5 months ago

Hi,

When I specify the W&B integration incorrectly in my code (see "foo" below):

created_job = self.client.jobs.create(
            model="open-mistral-7b",
            training_files=[training_file.id],
            validation_files=[validation_file.id],
            integrations=["foo"],
            hyperparameters=TrainingParameters(
                training_steps=1,
                learning_rate=0.0001,
            ),
            dry_run=dry_run
        )

It seems that some requests to W&B are tried and fail resulting after approx 30s into this error

File "/Users/didduran/dev/mistral-tunathon-private/venv/lib/python3.12/site-packages/mistralai/client.py", line 156, in _request
    raise MistralAPIStatusException.from_response(response, message=str(e)) from e
mistralai.exceptions.MistralAPIStatusException: Status: 500. Message: {"detail": "Internal Server Error"}

at this point in the code after max_retries is reached:

        except MistralAPIStatusException as e:
            attempt += 1
            if attempt > self._max_retries:
                raise MistralAPIStatusException.from_response(response, message=str(e)) from e
            backoff = 2.0**attempt  # exponential backoff
            time.sleep(backoff)

Wouldn't it be better to fail early after an initial parsing of 'ìntegrationsparamshowing that it is improperly specified ?

Best, Didier

jean-malo commented 4 months ago

thanks a lot for the report @didier-durand this has been fixed in the API, you will now receive an HTTP 422 error in case of badly formatted integration.

didier-durand commented 4 months ago

Avec plaisir!