argilla-io / argilla

Argilla is a collaboration tool for AI engineers and domain experts to build high-quality datasets
https://docs.argilla.io
Apache License 2.0
3.91k stars 368 forks source link

[BUG] Cannot save dataset settings programmatically #3149

Closed Fancman closed 1 year ago

Fancman commented 1 year ago

Describe the bug I wanted to set labels for existing dataset without labels programmatically. When I tried it, I got Error which is showed in picture bellow. In "Additional context" I described how I fixed it after investigating error.

image

Stacktrace and Code to create the bug

  1. Run Argilla with docker-compose as it is in documentation
  2. Initialize Argilla
    
    import argilla as rg

rg.init( api_url="http://localhost:6900/", api_key="argilla.apikey" )

3. Create dataset in it with log function
```python
rg.log(dataset_records, "dataset_name")
  1. Try to change dataset settings for example
    
    categories = ["Ring", "Necklace", "Earrings"]
    settings = rg.TextClassificationSettings(label_schema=categories)

rg.configure_dataset_settings(name=catalog_name, settings=settings)


5. Error happens

**Expected behavior**
Labels should be saved for Dataset and they should be visible in dataset setting page.

**Environment:**
 - Argilla Version: 1.9.0
 - ElasticSearch Version: 8.5.3
 - Docker Image (optional): argilla/argilla-server:latest

**Additional context**
In file `client/apis/datasets.py` HTTP client calls URL path `{self._API_PREFIX}/{dataset.name}/{dataset.task}/settings` which has object property `dataset.task` in it, which for me gives string `TaskType.text_classification`. So result URL is `/TaskType.text_classification/settings`. But Argilla server listens for path `/TextClassification/settings` as it is in REST API documentation.

I fixed error with changing dataset.task to dataset.task.value, after it worked as it is expected.

Before:

![image](https://github.com/argilla-io/argilla/assets/5480663/b4ed133e-3ad2-4c56-acef-f6a82d10c992)

After:

![image](https://github.com/argilla-io/argilla/assets/5480663/1496f288-2e0f-406a-afd3-ffa93d683f90)
alvarobartt commented 1 year ago

Right @Fancman, it seems that the Enum is being used but the string value should be used instead, feel free to open a PR for it! Thanks a lot 🤗

gabrielmbmb commented 1 year ago

hi @Fancman, thanks for reporting this issue! Which Python version are you using? 3.11?

Fancman commented 1 year ago

hi @Fancman, thanks for reporting this issue! Which Python version are you using? 3.11?

hi, yes, specifically Python 3.11.3. I am glad that I could help.