Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Experiment/add-record-to-draft-dataset #5555

Draft
wants to merge 3 commits into
base: experiment/records-for-draft-datasets
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion argilla/src/argilla/datasets/_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ def api_model(self) -> DatasetModel:

def _publish(self) -> "Dataset":
self._settings.create()
self._api.publish(dataset_id=self._model.id)
# self._api.publish(dataset_id=self._model.id)

return self.get()

Expand Down
178 changes: 178 additions & 0 deletions examples/add-records-to-draft-dataset.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/Users/ben/code/argilla/.venv/lib/python3.11/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n",
" from .autonotebook import tqdm as notebook_tqdm\n"
]
}
],
"source": [
"from uuid import uuid4\n",
"import argilla as rg"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/Users/ben/code/argilla/argilla/src/argilla/datasets/_resource.py:250: UserWarning: Workspace not provided. Using default workspace: argilla id: 735cae0d-eb08-45c3-ad79-0a11ad4dd2c2\n",
" warnings.warn(f\"Workspace not provided. Using default workspace: {workspace.name} id: {workspace.id}\")\n"
]
},
{
"data": {
"text/plain": [
"Dataset(id=UUID('bb50f766-f6f8-4526-a470-75757ae21fb3') inserted_at=datetime.datetime(2024, 10, 1, 9, 41, 14, 633100) updated_at=datetime.datetime(2024, 10, 1, 9, 41, 14, 644515) name='trtrt' status='draft' guidelines=None allow_extra_metadata=False distribution=OverlapTaskDistributionModel(strategy='overlap', min_submitted=1) workspace_id=UUID('735cae0d-eb08-45c3-ad79-0a11ad4dd2c2') last_activity_at=datetime.datetime(2024, 10, 1, 9, 41, 14, 644515))"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"client = rg.Argilla()\n",
"\n",
"dataset_name = \"trtrt\"\n",
"\n",
"dataset = rg.Dataset(\n",
" name=dataset_name,\n",
" settings=rg.Settings(\n",
" fields=[\n",
" rg.TextField(name=\"test_field\"),\n",
" ],\n",
" questions=[rg.RatingQuestion(name=\"test_question\", values=[1, 2, 3, 4, 5])],\n",
" ),\n",
")\n",
"dataset.create()"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">DatasetRecords: The provided batch size <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">256</span> was normalized. Using value <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">1</span>.\n",
"</pre>\n"
],
"text/plain": [
"DatasetRecords: The provided batch size \u001b[1;36m256\u001b[0m was normalized. Using value \u001b[1;36m1\u001b[0m.\n"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"Sending records...: 0%| | 0/1 [00:00<?, ?batch/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"Sending records...: 100%|██████████| 1/1 [00:00<00:00, 6.08batch/s]\n"
]
},
{
"data": {
"text/plain": [
"DatasetRecords(Dataset(id=UUID('bb50f766-f6f8-4526-a470-75757ae21fb3') inserted_at=datetime.datetime(2024, 10, 1, 9, 41, 14, 633100) updated_at=datetime.datetime(2024, 10, 1, 9, 41, 14, 644515) name='trtrt' status='draft' guidelines=None allow_extra_metadata=False distribution=OverlapTaskDistributionModel(strategy='overlap', min_submitted=1) workspace_id=UUID('735cae0d-eb08-45c3-ad79-0a11ad4dd2c2') last_activity_at=datetime.datetime(2024, 10, 1, 9, 41, 14, 644515)))"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"dataset.records.log(\n",
" [\n",
" {\n",
" \"test_field\": \"test\",\n",
" }\n",
" ]\n",
")"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"TextQuestion(name=feedback, title=feedback, description=None, type=text, required=True) "
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"dataset.settings.questions.add(rg.TextQuestion(\"feedback\"))"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"Dataset(id=UUID('bb50f766-f6f8-4526-a470-75757ae21fb3') inserted_at=datetime.datetime(2024, 10, 1, 9, 41, 14, 633100) updated_at=datetime.datetime(2024, 10, 1, 9, 41, 14, 644515) name='trtrt' status='draft' guidelines=None allow_extra_metadata=False distribution=OverlapTaskDistributionModel(strategy='overlap', min_submitted=1) workspace_id=UUID('735cae0d-eb08-45c3-ad79-0a11ad4dd2c2') last_activity_at=datetime.datetime(2024, 10, 1, 9, 41, 14, 644515))"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"dataset.update()"
]
}
],
"metadata": {
"kernelspec": {
"display_name": ".venv",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.9"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Loading