From 4de1b4a20545b1ae9b705af1dfa52277eac9b5ca Mon Sep 17 00:00:00 2001 From: Daniel Perrefort Date: Tue, 18 Aug 2026 08:42:15 -0400 Subject: [PATCH 1/2] Bumps dependencies in pyproject file --- poetry.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/poetry.lock b/poetry.lock index 08a3534..b7f36a0 100644 --- a/poetry.lock +++ b/poetry.lock @@ -197,18 +197,18 @@ zstd = ["zstandard (>=0.18.0)"] [[package]] name = "idna" -version = "3.18" +version = "3.19" description = "Internationalized Domain Names in Applications (IDNA)" optional = false python-versions = ">=3.9" groups = ["main"] files = [ - {file = "idna-3.18-py3-none-any.whl", hash = "sha256:7f952cbe720b688055e3f87de14f5c3e5fdaa8bc3928985c4077ca689de849a2"}, - {file = "idna-3.18.tar.gz", hash = "sha256:ffb385a7e039654cef1ab9ef32c6fafe283c0c0467bba1d9029738ce4a14a848"}, + {file = "idna-3.19-py3-none-any.whl", hash = "sha256:815e7be7a7806d54abb586dc943addc79e8b2ee16915059658cbeff4b1b43bf4"}, + {file = "idna-3.19.tar.gz", hash = "sha256:5e0811a4383b21dc5838069f801c4fb62113b7447663d2530d2bd6e77b49bf15"}, ] [package.extras] -all = ["mypy (>=1.11.2)", "pytest (>=8.3.2)", "ruff (>=0.6.2)"] +all = ["coverage (>=7.10.0)", "hypothesis (>=6.141.1)", "mypy (>=1.11.2)", "pytest (>=8.3.2)", "ruff (>=0.16.0)", "ty (>=0.0.37)"] [[package]] name = "typing-extensions" From 142483ba7ae6d59089a4a16ecfe9041a5cbe8acc Mon Sep 17 00:00:00 2001 From: Daniel Perrefort Date: Thu, 27 Aug 2026 22:33:57 -0400 Subject: [PATCH 2/2] Drops project documentation directory --- docs/index.md | 12 ----- docs/logging.md | 54 --------------------- docs/started.md | 123 ------------------------------------------------ 3 files changed, 189 deletions(-) delete mode 100644 docs/index.md delete mode 100644 docs/logging.md delete mode 100644 docs/started.md diff --git a/docs/index.md b/docs/index.md deleted file mode 100644 index 0bfa509..0000000 --- a/docs/index.md +++ /dev/null @@ -1,12 +0,0 @@ -# Keystone Python Client - -Keystone provides an official Python client designed to simplify integration with the platform's [REST API](../../keystone-api/). -It handles authentication, request execution, and response parsing, allowing developers to concentrate on application -logic rather than API mechanics. - -The client is published on the BHPC package registry and can be installed using the `pip` package manager: - -```sh -BHPC_REPO="https://dl.cloudsmith.io/public/better-hpc/keystone/python/simple/" -pip install --extra-index-url=$BHPC_REPO keystone-api-client -``` diff --git a/docs/logging.md b/docs/logging.md deleted file mode 100644 index a2fbabc..0000000 --- a/docs/logging.md +++ /dev/null @@ -1,54 +0,0 @@ -# Application Logging - -The `kclient` Python logger is automatically registered on package import. -It provides full compatibility with the standard Python `logging` module and can be accessed and customized in the -standard fashion. - -```python -import logging -import keystone_client - -handler = logging.StreamHandler() -handler.setFormatter( - logging.Formatter('%(asctime)s %(levelname)s %(name)s: %(message)s') -) - -logging.getLogger('kclient').addHandler(handler) -``` - -## Custom Logging Fields - -In addition to Python's built-in message fields, the `kclient` logger also exposes the following package-specific values. -These fields are passed to all log messages and may be accessed via custom formatters or filters. - -| Field Name | Description | -|---------------|----------------------------------------------------------------------------| -| `cid` | Per-session logging id used to correlate requests across a client session. | -| `baseurl` | Base API server URL, including http protocol. | -| `method` | HTTP method for outgoing requests, or an empty string if not applicable. | -| `endpoint` | API endpoint for outgoing requests, or an empty string if not applicable. | -| `url` | Full API URL for outgoing requests, or an empty string if not applicable. | -| `status_code` | HTTP response status code, or an empty string if not applicable. | - -## Session IDs - -Each client session is assigned a unique correlation ID (CID) that accompanies all emitted log records. -CID values are accessible as logging fields or directly from an active client session, demonstrated below: - -=== "Synchronous" - - ```python - from keystone_client import KeystoneClient - - with KeystoneClient(url="http://localhost:8000") as client: - print(client.cid) - ``` - -=== "Asynchronous" - - ```python - from keystone_client import AsyncKeystoneClient - - async with AsyncKeystoneClient(url="http://localhost:8000") as aclient: - print(aclient.cid) - ``` diff --git a/docs/started.md b/docs/started.md deleted file mode 100644 index 7f77e1a..0000000 --- a/docs/started.md +++ /dev/null @@ -1,123 +0,0 @@ -# Getting Started - -The `KeystoneClient` and `AsyncKeystoneClient` classes offer a streamlined, session-based interface for interacting with -the Keystone API. They automatically manage common connection settings to ensure requests are submitted efficiently -and abstract away low level API mechanics so developers can focus on application logic. - -## Instantiating a Client - -The following example instantiates a new session for a locally running server on port `8000`. -Creating the session with a context manager ensures open connections are automatically closed when no longer in use. - -=== "Synchronous" - - ```python - from keystone_client import KeystoneClient - - with KeystoneClient(url="http://localhost:8000") as client: - ... # Your synchronous code here - ``` - -=== "Asynchronous" - - ```python - from keystone_client import AsyncKeystoneClient - - async with AsyncKeystoneClient(url="http://localhost:8000") as aclient: - ... # Your asynchronous code here - ``` - -Sessions can also be opened and closed manually, although this approach is generally discouraged as it increases -the likelihood of resource leaks and unclosed connections. - -=== "Synchronous" - - ```python - from keystone_client import KeystoneClient - - client = KeystoneClient(url="http://localhost:8000"): - # Your synchronous code here - client.close() - ``` - -=== "Asynchronous" - - ```python - from keystone_client import AsyncKeystoneClient - - aclient = AsyncKeystoneClient(url="http://localhost:8000"): - # Your asynchronous code here - await aclient.close() - ``` - -## Authenticating a Session - -The `login` and `logout` methods are used to handle user authentication. -Once authenticated, the client will automatically manage the resulting session tokens. - -=== "Synchronous" - - ```python - from keystone_client import KeystoneClient - - with KeystoneClient(url="http://localhost:8000") as client: - client.login(username="username", password="password") - assert client.is_authenticated() - client.logout() - ``` - -=== "Asynchronous" - - ```python - from keystone_client import AsyncKeystoneClient - - async with AsyncKeystoneClient(url="http://localhost:8000") as aclient: - await aclient.login(username="username", password="password") - assert await aclient.is_authenticated() - await aclient.logout() - ``` - -## Making API Requests - -Client classes provide dedicated methods for each HTTP request type supported by the API. -Any relevant session/authentication tokens are included automatically when submitting requests. - -| HTTP Method | Function Name | Description | -|-------------|---------------|----------------------------------------------------------| -| `GET` | `http_get` | Retrieve data from the server at the specified resource. | -| `POST` | `http_post` | Submit a new record to be processed by the server. | -| `PUT` | `http_put` | Replace an existing record with a new one. | -| `PATCH` | `http_patch` | Partially update an existing record. | -| `DELETE` | `http_delete` | Remove the specified record from the server. | - -Request/response logic is handled using the `httpx` library. -API responses are returned as `httpx.Response` objects which encapsulate the response data and status code. -Users are encouraged to familiarize themselves with the `httpx` library and it's methods for parsing response -data and related metadata. -A simple example is provided below. - -=== "Synchronous" - - ```python - from keystone_client import KeystoneClient - - with KeystoneClient(url="http://localhost:8000") as client: - response = client.http_get('version') - - response.raise_for_status() - print(response.status_code) - print(response.content) - ``` - -=== "Asynchronous" - - ```python - from keystone_client import AsyncKeystoneClient - - async with AsyncKeystoneClient(url="http://localhost:8000") as aclient: - response = await aclient.http_get('version') - - response.raise_for_status() - print(response.status_code) - print(response.content) - ```