Argilla: dataset.create() failing in my Organization space

Hey all! I’m trying to get up and running w/ Argilla for labeling, in the default setup in HuggingFace Spaces, with an Organization-owned Space.

I got this working easily in a Space in my personal account. I was able to create the dataset, add records, curate using the UI, etc.

However, I’m running into a permissions issue when calling database.create() for a Space that I created in my Organization. I’ve pasted the full stack trace below.

My Organization (Intertru) doesn’t yet have an Enterprise subscription, so I’m using the Argilla URL and key for the Organization with my access key from my personal account which is linked to the Organization. Is this expected to work? If not, must the Organization be an Enterprise account so I can use Argilla in it? I want this dataset to be private and to be available to labelers in my company.

Thanks!

HTTPStatusError                           Traceback (most recent call last)
File /opt/conda/lib/python3.10/site-packages/argilla/_exceptions/_api.py:91, in api_error_handler.<locals>._handler_wrapper(*args, **kwargs)
     90 try:
---> 91     return func(*args, **kwargs)
     92 except HTTPStatusError as e:

File /opt/conda/lib/python3.10/site-packages/argilla/_api/_datasets.py:45, in DatasetsAPI.create(self, dataset)
     41 response = self.http_client.post(
     42     url=self.url_stub,
     43     json=json_body,
     44 )
---> 45 response.raise_for_status()
     46 response_json = response.json()

File /opt/conda/lib/python3.10/site-packages/httpx/_models.py:761, in Response.raise_for_status(self)
    760 message = message.format(self, error_type=error_type)
--> 761 raise HTTPStatusError(message, request=request, response=self)

HTTPStatusError: Client error '403 Forbidden' for url 'https://intertru-argilla.hf.space/api/v1/datasets'
For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/403

During handling of the above exception, another exception occurred:

ForbiddenError                            Traceback (most recent call last)
Cell In[31], line 7
      1 dataset = rg.Dataset(
      2     name=f"my_first_dataset",
      3     settings=settings,
      4     client=rg_client,
      5     workspace="argilla"
      6 )
----> 7 dataset.create()

File /opt/conda/lib/python3.10/site-packages/argilla/datasets/_resource.py:160, in Dataset.create(self)
    154 def create(self) -> "Dataset":
    155     """Creates the dataset on the server with the `Settings` configuration.
    156 
    157     Returns:
    158         Dataset: The created dataset object.
    159     """
--> 160     super().create()
    161     try:
    162         return self._publish()

File /opt/conda/lib/python3.10/site-packages/argilla/_resource.py:86, in Resource.create(self)
     85 def create(self) -> "Resource":
---> 86     response_model = self._api.create(self.api_model())
     87     self._model = response_model
     88     self._update_last_api_call()

File /opt/conda/lib/python3.10/site-packages/argilla/_exceptions/_api.py:93, in api_error_handler.<locals>._handler_wrapper(*args, **kwargs)
     91     return func(*args, **kwargs)
     92 except HTTPStatusError as e:
---> 93     _error_switch(status_code=e.response.status_code, error_detail=e.response.text)

File /opt/conda/lib/python3.10/site-packages/argilla/_exceptions/_api.py:87, in api_error_handler.<locals>._error_switch(status_code, error_detail)
     77 switch = {
     78     400: BadRequestError,
     79     401: UnauthorizedError,
   (...)
     84     500: InternalServerError,
     85 }
     86 exception_class = switch.get(status_code, ArgillaAPIError)
---> 87 raise exception_class(f"{exception_class.message}. Details: {error_detail}", status_code=status_code)

ForbiddenError: Argilla SDK error: ForbiddenError: Forbidden request to the server. Details: {"detail":{"code":"argilla.api.errors::ForbiddenOperationError","params":{"detail":"Operation not allowed"}}}
1 Like

I’m totally stuck on this, so I sure hope that someone has a clue for me…

1 Like

Hi! I was experiencing the same issue with an Argilla 2.x server hosted in an organization space - it turned out that I was using the wrong API key to make the initial configuration of workspaces and datasets. I had signed into the space with my HF credentials, my user’s API key had the “annotator” permissions level by default.

Make sure you’re using an API key with a sufficient permissions level. The key for the “Owner” user is a safe bet - if you didn’t specify this key when you set up the space, it can be found toward the end of the build logs when your space starts up. Hope this helps!

1 Like

Copying this here from Discord:

  1. AHA, I see the user-settings says that I’m an annotator . Trying to figure out how to change this now.

  2. [3:35 PM]

I’m not familar with the auth model generally for HF, and am finding it a bit confusing.

Another thing that was tripping me up was that I didn’t realize that the top menu was hidden behind this, so I couldn’t figure out how to get to the settings and such:


  1. What I did to fix the issue was to create a new Argilla Space and put my HF username in the Username field of the Secrets section of the form. I left the Password field empty, to keep OAuth. When I logged into HF for this new space, I was assigned the Owner role. I also got tripped up briefly by the fact that the ARGILLA_API_KEY is different in different spaces. Makes sense, but something to note for those who come after.

  2. [4:30 PM]

Everything is working now. Thanks for the hint, @David Berenstein !

tl;dr: it should be better documented how the user has to fill in the Username field and leave the Password field blank, when creating an Argilla Space on HF. It’d be even better if the Space-creation UI asked the user which case they are trying to create (only in the user’s account, in an org account, etc) and guided them through the setup more cleanly.