From 2ab51e4d3d9d7f85594433ce40079b5f036408a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Francisco=20Calvo?= Date: Mon, 6 May 2024 10:49:27 +0200 Subject: [PATCH 1/9] chore: set package version to 1.28.0 --- src/argilla_server/_version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/argilla_server/_version.py b/src/argilla_server/_version.py index 7147d852..24eaeab7 100644 --- a/src/argilla_server/_version.py +++ b/src/argilla_server/_version.py @@ -13,4 +13,4 @@ # limitations under the License. # coding: utf-8 -__version__ = "1.28.0-dev" +__version__ = "1.28.0" From 0b960dd30e9ba5302667be363649bb8adb07e64c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Francisco=20Calvo?= Date: Mon, 6 May 2024 11:00:07 +0200 Subject: [PATCH 2/9] chore: upgrade argilla submodule to use latests changes from releases/1.28.0 branch --- argilla | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/argilla b/argilla index 92c78151..8aca5fe2 160000 --- a/argilla +++ b/argilla @@ -1 +1 @@ -Subproject commit 92c78151ab33680eefd55832eca0a8e17af2ce77 +Subproject commit 8aca5fe29449169b8f840f5ee4b0a3462974be8f From 6c920f277717124708ac2a31fffe7f5b691e7d68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Francisco=20Calvo?= Date: Mon, 6 May 2024 11:41:28 +0200 Subject: [PATCH 3/9] chore: upgrade CHANGELOG.md --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index be949771..9ca3d35e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,8 @@ These are the section headers that we use: ## [Unreleased]() +## [1.28.0](https://github.com/argilla-io/argilla-server/compare/v1.27.0...v1.28.0) + ### Added - Added support to specify a list of score values for suggestions `score` attribute. ([#98](https://github.com/argilla-io/argilla-server/pull/98)) From 0b98d7ebc1b65edf23777f1526e0dcd7d150736b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Francisco=20Calvo?= Date: Tue, 7 May 2024 11:05:14 +0200 Subject: [PATCH 4/9] chore: upgrade argilla submodule with latests changes from releases/1.28.0 branch --- argilla | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/argilla b/argilla index 8aca5fe2..bb0ba3fa 160000 --- a/argilla +++ b/argilla @@ -1 +1 @@ -Subproject commit 8aca5fe29449169b8f840f5ee4b0a3462974be8f +Subproject commit bb0ba3fa2986caa9279d5122a4e40e1dbbb1c014 From 105f0acdec068002e49b6ba4f70ce4a06d086247 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Francisco=20Calvo?= Date: Wed, 8 May 2024 10:26:37 +0200 Subject: [PATCH 5/9] chore: update argilla submodule with latests changes from releases/1.28.0 branch --- argilla | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/argilla b/argilla index bb0ba3fa..cecd7d9e 160000 --- a/argilla +++ b/argilla @@ -1 +1 @@ -Subproject commit bb0ba3fa2986caa9279d5122a4e40e1dbbb1c014 +Subproject commit cecd7d9e0545d0d55c8277b681dc1aeb792c154b From 1f0843b936680bc01f968c17f43141441840194f Mon Sep 17 00:00:00 2001 From: Francisco Aranda Date: Wed, 8 May 2024 15:55:11 +0200 Subject: [PATCH 6/9] fix(telemetry): Identify user with system info (#154) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # Description This PR adds the telemetry context attributes as part of the user traits since the context values are not available for analytics. **Type of change** (Please delete options that are not relevant. Remember to title the PR according to the type of change) - [X] Bug fix (non-breaking change which fixes an issue) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) **How Has This Been Tested** (Please describe the tests that you ran to verify your changes. And ideally, reference `tests`) - [ ] Test A - [ ] Test B **Checklist** - [ ] I followed the style guidelines of this project - [ ] I did a self-review of my code - [ ] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] I filled out [the contributor form](https://tally.so/r/n9XrxK) (see text above) - [ ] I have added relevant notes to the `CHANGELOG.md` file (See https://keepachangelog.com/) --- src/argilla_server/telemetry.py | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/src/argilla_server/telemetry.py b/src/argilla_server/telemetry.py index 7bd23c50..83e2aa75 100644 --- a/src/argilla_server/telemetry.py +++ b/src/argilla_server/telemetry.py @@ -54,13 +54,6 @@ def server_id(self) -> uuid.UUID: def __post_init__(self, enable_telemetry: bool, disable_send: bool, api_key: str, host: str): from argilla_server._version import __version__ - self.client = None - if enable_telemetry: - try: - self.client = Client(write_key=api_key, gzip=True, host=host, send=not disable_send, max_retries=10) - except Exception as err: - _LOGGER.warning(f"Cannot initialize telemetry. Error: {err}. Disabling...") - self._server_id = uuid.UUID(int=uuid.getnode()) self._system_info = { "system": platform.system(), @@ -74,19 +67,30 @@ def __post_init__(self, enable_telemetry: bool, disable_send: bool, api_key: str } _LOGGER.info("System Info:") - _LOGGER.info(json.dumps(self._system_info, indent=2)) + _LOGGER.info(f"Server id: {self.server_id}") + _LOGGER.info(f"Context: {json.dumps(self._system_info, indent=2)}") + + self.client: Optional[Client] = None + if enable_telemetry: + try: + client = Client(write_key=api_key, gzip=True, host=host, send=not disable_send, max_retries=10) + client.identify(user_id=str(self._server_id), traits=self._system_info) + + self.client = client + except Exception as err: + _LOGGER.warning(f"Cannot initialize telemetry. Error: {err}. Disabling...") def track_data(self, action: str, data: Dict[str, Any], include_system_info: bool = True): if not self.client: return event_data = data.copy() - self.client.track( - user_id=str(self._server_id), - event=action, - properties=event_data, - context=self._system_info if include_system_info else {}, - ) + + context = {} + if include_system_info: + context = self._system_info.copy() + + self.client.track(user_id=str(self._server_id), event=action, properties=event_data, context=context) _CLIENT = TelemetryClient() From f6cf4fc8e3617f04e2f7322ddf6752fff6d7c648 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Francisco=20Calvo?= Date: Thu, 9 May 2024 12:06:08 +0200 Subject: [PATCH 7/9] fix: HF typo using persistent instead of persistant (#160) # Description We know that the exposed environment variable from HF has a typo using `PERSISTANT_STORAGE_ENABLED` instead of `PERSISTENT_STORAGE_ENABLED`. Instead of aligning with that typo with this PR we will use the correct spelling even if internally we are using the HF environment variable with the typo. Refs #123 **Type of change** (Please delete options that are not relevant. Remember to title the PR according to the type of change) - [x] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] Refactor (change restructuring the codebase without changing functionality) - [ ] Improvement (change adding some improvement to an existing functionality) - [ ] Documentation update **How Has This Been Tested** (Please describe the tests that you ran to verify your changes. And ideally, reference `tests`) - [x] Tests should be passing. **Checklist** - [ ] I added relevant documentation - [ ] follows the style guidelines of this project - [ ] I did a self-review of my code - [ ] I made corresponding changes to the documentation - [ ] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] I filled out [the contributor form](https://tally.so/r/n9XrxK) (see text above) - [ ] I have added relevant notes to the CHANGELOG.md file (See https://keepachangelog.com/) --- CHANGELOG.md | 2 +- src/argilla_server/contexts/settings.py | 4 ++-- src/argilla_server/schemas/v1/settings.py | 6 ++++-- src/argilla_server/settings.py | 4 ++-- tests/unit/api/v1/settings/test_get_settings.py | 10 +++++----- 5 files changed, 14 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ca3d35e..273c242d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,7 +22,7 @@ These are the section headers that we use: - Added support to specify a list of score values for suggestions `score` attribute. ([#98](https://github.com/argilla-io/argilla-server/pull/98)) - Added `GET /api/v1/settings` new endpoint exposing Argilla and Hugging Face settings when available. ([#127](https://github.com/argilla-io/argilla-server/pull/127)) -- Added `ARGILLA_SHOW_HUGGINGFACE_SPACE_PERSISTANT_STORAGE_WARNING` new environment variable to disable warning message when Hugging Face Spaces persistent storage is disabled. ([#124](https://github.com/argilla-io/argilla-server/pull/124)) +- Added `ARGILLA_SHOW_HUGGINGFACE_SPACE_PERSISTENT_STORAGE_WARNING` new environment variable to disable warning message when Hugging Face Spaces persistent storage is disabled. ([#124](https://github.com/argilla-io/argilla-server/pull/124)) - Added `options_order` new settings attribute to support specify an order for options in multi label selection questions. ([#133](https://github.com/argilla-io/argilla-server/pull/133)) - Added `POST /api/v1/datasets/:dataset_id/records/bulk` endpoint. ([#106](https://github.com/argilla-io/argilla-server/pull/106)) - Added `PUT /api/v1/datasets/:dataset_id/records/bulk` endpoint. ([#106](https://github.com/argilla-io/argilla-server/pull/106)) diff --git a/src/argilla_server/contexts/settings.py b/src/argilla_server/contexts/settings.py index 8adedf54..38a8a6ae 100644 --- a/src/argilla_server/contexts/settings.py +++ b/src/argilla_server/contexts/settings.py @@ -31,8 +31,8 @@ def _get_argilla_settings() -> ArgillaSettings: argilla_settings = ArgillaSettings() if _get_huggingface_settings(): - argilla_settings.show_huggingface_space_persistant_storage_warning = ( - settings.show_huggingface_space_persistant_storage_warning + argilla_settings.show_huggingface_space_persistent_storage_warning = ( + settings.show_huggingface_space_persistent_storage_warning ) return argilla_settings diff --git a/src/argilla_server/schemas/v1/settings.py b/src/argilla_server/schemas/v1/settings.py index 935c9c63..89bad9bf 100644 --- a/src/argilla_server/schemas/v1/settings.py +++ b/src/argilla_server/schemas/v1/settings.py @@ -18,7 +18,7 @@ class ArgillaSettings(BaseModel): - show_huggingface_space_persistant_storage_warning: Optional[bool] + show_huggingface_space_persistent_storage_warning: Optional[bool] class HuggingfaceSettings(BaseSettings): @@ -28,7 +28,9 @@ class HuggingfaceSettings(BaseSettings): space_host: str = Field(None, env="SPACE_HOST") space_repo_name: str = Field(None, env="SPACE_REPO_NAME") space_author_name: str = Field(None, env="SPACE_AUTHOR_NAME") - space_persistant_storage_enabled: bool = Field(False, env="PERSISTANT_STORAGE_ENABLED") + # NOTE: Hugging Face has a typo in their environment variable name, + # using PERSISTANT instead of PERSISTENT. We will use the correct spelling in our code. + space_persistent_storage_enabled: bool = Field(False, env="PERSISTANT_STORAGE_ENABLED") @property def is_running_on_huggingface(self) -> bool: diff --git a/src/argilla_server/settings.py b/src/argilla_server/settings.py index 36c7d20f..58e936a7 100644 --- a/src/argilla_server/settings.py +++ b/src/argilla_server/settings.py @@ -128,9 +128,9 @@ class Settings(BaseSettings): ) # Hugging Face settings - show_huggingface_space_persistant_storage_warning: bool = Field( + show_huggingface_space_persistent_storage_warning: bool = Field( default=True, - description="If True, show a warning when Hugging Face space persistant storage is disabled", + description="If True, show a warning when Hugging Face space persistent storage is disabled", ) # See also the telemetry.py module diff --git a/tests/unit/api/v1/settings/test_get_settings.py b/tests/unit/api/v1/settings/test_get_settings.py index 087df557..f5d3d7bc 100644 --- a/tests/unit/api/v1/settings/test_get_settings.py +++ b/tests/unit/api/v1/settings/test_get_settings.py @@ -34,26 +34,26 @@ async def test_get_settings_for_argilla_settings_running_on_huggingface(self, as assert response.status_code == 200 assert response.json()["argilla"] == { - "show_huggingface_space_persistant_storage_warning": True, + "show_huggingface_space_persistent_storage_warning": True, } async def test_get_settings_for_argilla_settings_running_on_huggingface_with_disabled_storage_warning( self, async_client: AsyncClient ): with mock.patch.object(HUGGINGFACE_SETTINGS, "space_id", "space-id"): - with mock.patch.object(argilla_server_settings, "show_huggingface_space_persistant_storage_warning", False): + with mock.patch.object(argilla_server_settings, "show_huggingface_space_persistent_storage_warning", False): response = await async_client.get(self.url()) assert response.status_code == 200 assert response.json()["argilla"] == { - "show_huggingface_space_persistant_storage_warning": False, + "show_huggingface_space_persistent_storage_warning": False, } async def test_get_settings_for_argilla_settings_not_running_on_huggingface(self, async_client: AsyncClient): response = await async_client.get(self.url()) assert response.status_code == 200 - assert "show_huggingface_space_persistant_storage_warning" not in response.json()["argilla"] + assert "show_huggingface_space_persistent_storage_warning" not in response.json()["argilla"] async def test_get_settings_for_huggingface_settings_running_on_huggingface(self, async_client: AsyncClient): huggingface_os_environ = { @@ -78,7 +78,7 @@ async def test_get_settings_for_huggingface_settings_running_on_huggingface(self "space_host": "space-host", "space_repo_name": "space-repo-name", "space_author_name": "space-author-name", - "space_persistant_storage_enabled": True, + "space_persistent_storage_enabled": True, } async def test_get_settings_for_huggingface_settings_not_running_on_huggingface(self, async_client: AsyncClient): From 46899a6d9c71da81130e5230a8797e0903a504fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Francisco=20Calvo?= Date: Thu, 9 May 2024 12:08:16 +0200 Subject: [PATCH 8/9] chore: update argilla submodule with latests changes from releases/1.28.0 branch --- argilla | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/argilla b/argilla index cecd7d9e..f5ae9b49 160000 --- a/argilla +++ b/argilla @@ -1 +1 @@ -Subproject commit cecd7d9e0545d0d55c8277b681dc1aeb792c154b +Subproject commit f5ae9b49a9163739c9463ab57427b25e3b7ee34f From 5989978f9a47f2755313c879ec1165459b776e0d Mon Sep 17 00:00:00 2001 From: Francisco Aranda Date: Thu, 9 May 2024 13:33:12 +0200 Subject: [PATCH 9/9] feat(telemetry): Define three types of deployments (#159) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # Description This PR divide deployment into 3 different types: `server`, `quickstart` and `huggingface_space`. **Type of change** (Please delete options that are not relevant. Remember to title the PR according to the type of change) - [ ] New feature (non-breaking change which adds functionality) - [ ] Refactor (change restructuring the codebase without changing functionality) - [X] Improvement (change adding some improvement to an existing functionality) **How Has This Been Tested** (Please describe the tests that you ran to verify your changes. And ideally, reference `tests`) - [ ] Test A - [ ] Test B **Checklist** - [ ] I added relevant documentation - [ ] I followed the style guidelines of this project - [ ] I did a self-review of my code - [ ] I made corresponding changes to the documentation - [ ] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] I filled out [the contributor form](https://tally.so/r/n9XrxK) (see text above) - [ ] I have added relevant notes to the `CHANGELOG.md` file (See https://keepachangelog.com/) --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- src/argilla_server/telemetry.py | 6 +++- src/argilla_server/utils/_telemetry.py | 45 +++++++++++++------------- 2 files changed, 27 insertions(+), 24 deletions(-) diff --git a/src/argilla_server/telemetry.py b/src/argilla_server/telemetry.py index 83e2aa75..c9a4d266 100644 --- a/src/argilla_server/telemetry.py +++ b/src/argilla_server/telemetry.py @@ -25,7 +25,11 @@ from argilla_server.constants import DEFAULT_USERNAME from argilla_server.models import User from argilla_server.settings import settings -from argilla_server.utils._telemetry import is_running_on_docker_container, server_deployment_type +from argilla_server.utils._telemetry import ( + is_running_on_docker_container, + is_running_on_huggingface_space, + server_deployment_type, +) try: from analytics import Client # This import works only for version 2.2.0 diff --git a/src/argilla_server/utils/_telemetry.py b/src/argilla_server/utils/_telemetry.py index 15332544..72c97c79 100644 --- a/src/argilla_server/utils/_telemetry.py +++ b/src/argilla_server/utils/_telemetry.py @@ -11,10 +11,10 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. - +import logging import os -import psutil +_LOGGER = logging.getLogger(__name__) def server_deployment_type() -> str: @@ -22,20 +22,31 @@ def server_deployment_type() -> str: global _server_deployment_type if _server_deployment_type is None: - _server_deployment_type = "server" - - if is_running_on_docker_container() and _is_quickstart_env(): + if is_running_on_huggingface_space(): + _server_deployment_type = "huggingface_space" + elif _is_quickstart_env(): _server_deployment_type = "quickstart" - + else: + _server_deployment_type = "server" return _server_deployment_type +def is_running_on_huggingface_space() -> bool: + """Returns True if the current process is running inside a Huggingface Space, False otherwise.""" + from argilla_server.schemas.v1.settings import HuggingfaceSettings + + return HuggingfaceSettings().is_running_on_huggingface + + def is_running_on_docker_container() -> bool: """Returns True if the current process is running inside a Docker container, False otherwise.""" global _in_docker_container if _in_docker_container is None: - _in_docker_container = _has_docker_env() or _has_docker_cgroup() + if is_running_on_huggingface_space(): + _in_docker_container = True + else: + _in_docker_container = _has_docker_env() or _has_docker_cgroup() return _in_docker_container @@ -43,7 +54,8 @@ def is_running_on_docker_container() -> bool: def _has_docker_env() -> bool: try: return os.path.exists("/.dockerenv") - except: + except Exception as e: + _LOGGER.warning(f"Error while checking if running in Docker: {e}") return False @@ -55,23 +67,11 @@ def _has_docker_cgroup() -> bool: and os.path.isfile(cgroup_path) and any("docker" in line for line in open(cgroup_path)) ) - except: + except Exception as e: + _LOGGER.warning(f"Error while checking if running in Docker: {e}") return False -def _is_quickstart_script_running() -> bool: - # TODO: Any modification in the `quickstart.Dockerfile` file should be reflected here - - try: - cmdline_key = "cmdline" - for process in psutil.process_iter([cmdline_key]): - if "start_quickstart_argilla.sh" in process.info[cmdline_key]: - return True - except: - pass - return False - - def _is_quickstart_env(): # TODO: Any modification in the `quickstart.Dockerfile` file should be reflected here @@ -84,7 +84,6 @@ def _is_quickstart_env(): "ADMIN_API_KEY", "ANNOTATOR_USERNAME", "ANNOTATOR_PASSWORD", - "LOAD_DATASETS", ]: if env_var not in os.environ: return False