Skip to content
Merged
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 .github/workflows/meta-sync-labels.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
private-key: "${{ secrets.BOT_APP_PRIVATE_KEY }}"

- name: Set up git repository
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
token: "${{ steps.app-token.outputs.token }}"

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pre-commit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1

- name: Install uv
uses: astral-sh/setup-uv@1e862dfacbd1d6d858c55d9b792c756523627244 # v7.1.4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1

- name: Install uv
uses: astral-sh/setup-uv@1e862dfacbd1d6d858c55d9b792c756523627244 # v7.1.4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/renovate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:
private-key: "${{ secrets.BOT_APP_PRIVATE_KEY }}"

- name: Checkout
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
token: "${{ steps.app-token.outputs.token }}"

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/rigging_pr_description.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ jobs:
contents: read

steps:
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
fetch-depth: 0 # full history for proper diffing

- name: Set up Python
uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0
uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0
with:
python-version: "3.13"

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/semgrep.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:

steps:
- name: Set up git repository
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
token: ${{ secrets.GITHUB_TOKEN }}

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/template-sync.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
owner: "${{ github.repository_owner }}"

- name: Checkout
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
token: "${{ steps.app-token.outputs.token }}"

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1

- name: Install uv
uses: astral-sh/setup-uv@1e862dfacbd1d6d858c55d9b792c756523627244 # v7.1.4
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ repos:

# Python code security
- repo: https://github.com/PyCQA/bandit
rev: 1.9.1
rev: 1.9.2
hooks:
- id: bandit
name: Code security checks
Expand Down
18 changes: 9 additions & 9 deletions docs/sdk/api.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@ def create_dataset(

```python
create_project(
name: str | UUID | None = None,
name: str,
key: str,
workspace_id: UUID | None = None,
organization_id: UUID | None = None,
) -> Project
Expand All @@ -175,9 +176,7 @@ Creates a new project.
**Parameters:**

* **`name`**
(`str | UUID | None`, default:
`None`
)
(`str`)
–The name of the project. If None, a default name will be used.
* **`workspace_id`**
(`UUID | None`, default:
Expand All @@ -199,7 +198,8 @@ Creates a new project.
```python
def create_project(
self,
name: str | UUID | None = None,
name: str,
key: str,
workspace_id: UUID | None = None,
organization_id: UUID | None = None,
) -> Project:
Expand All @@ -214,8 +214,8 @@ def create_project(
Project: The created Project object.
"""
payload: dict[str, t.Any] = {}
if name is not None:
payload["name"] = name
payload["name"] = name
payload["key"] = key
if workspace_id is not None:
payload["workspace_id"] = str(workspace_id)
if organization_id is not None:
Expand Down Expand Up @@ -995,7 +995,7 @@ Retrieves details of a specific project.

* **`project_identifier`**
(`str | UUID`)
–The project identifier. ID, name, or slug.
–The project identifier. ID or key.

**Returns:**

Expand All @@ -1008,7 +1008,7 @@ def get_project(self, project_identifier: str | UUID, workspace_id: UUID) -> Pro
"""Retrieves details of a specific project.

Args:
project_identifier (str | UUID): The project identifier. ID, name, or slug.
project_identifier (str | UUID): The project identifier. ID or key.

Returns:
Project: The Project object.
Expand Down
6 changes: 4 additions & 2 deletions dreadnode/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@
push_update = DEFAULT_INSTANCE.push_update
tag = DEFAULT_INSTANCE.tag
load_dataset = DEFAULT_INSTANCE.load_dataset
save_dataset = DEFAULT_INSTANCE.save_dataset
save_dataset_to_disk = DEFAULT_INSTANCE.save_dataset_to_disk
push_dataset = DEFAULT_INSTANCE.push_dataset
get_run_context = DEFAULT_INSTANCE.get_run_context
continue_run = DEFAULT_INSTANCE.continue_run
log_metric = DEFAULT_INSTANCE.log_metric
Expand Down Expand Up @@ -134,9 +135,10 @@
"logging",
"meta",
"optimization",
"push_dataset",
"push_update",
"run",
"save_dataset",
"save_dataset_to_disk",
"scorer",
"scorers",
"shutdown",
Expand Down
64 changes: 43 additions & 21 deletions dreadnode/api/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
from dreadnode.api.models import (
AccessRefreshTokenResponse,
ContainerRegistryCredentials,
CreateDatasetRequest,
CreateDatasetResponse,
DatasetDownloadRequest,
DatasetDownloadResponse,
DatasetMetadata,
DatasetUploadComplete,
DatasetUploadRequest,
DatasetUploadResponse,
DatasetUploadCompleteRequest,
DeviceCodeResponse,
ExportFormat,
GithubTokenResponse,
Expand Down Expand Up @@ -294,7 +294,7 @@ def get_project(self, project_identifier: str | UUID, workspace_id: UUID) -> Pro
"""Retrieves details of a specific project.

Args:
project_identifier (str | UUID): The project identifier. ID, name, or slug.
project_identifier (str | UUID): The project identifier. ID or key.

Returns:
Project: The Project object.
Expand All @@ -308,7 +308,8 @@ def get_project(self, project_identifier: str | UUID, workspace_id: UUID) -> Pro

def create_project(
self,
name: str | UUID | None = None,
name: str,
key: str,
workspace_id: UUID | None = None,
organization_id: UUID | None = None,
) -> Project:
Expand All @@ -323,8 +324,8 @@ def create_project(
Project: The created Project object.
"""
payload: dict[str, t.Any] = {}
if name is not None:
payload["name"] = name
payload["name"] = name
payload["key"] = key
if workspace_id is not None:
payload["workspace_id"] = str(workspace_id)
if organization_id is not None:
Expand Down Expand Up @@ -759,14 +760,26 @@ def export_timeseries(

# User data access

def get_user_data_credentials(self) -> UserDataCredentials:
def get_user_data_credentials(
self,
organization_id: UUID | None = None,
workspace_id: UUID | None = None,
dataset_id: UUID | None = None,
) -> UserDataCredentials:
"""
Retrieves user data credentials for secondary storage access.

Returns:
The user data credentials object.
"""
response = self._request("GET", "/user-data/credentials")
params: dict[str, str] = {}
if organization_id:
params["org_id"] = str(organization_id)
if workspace_id:
params["workspace_id"] = str(workspace_id)
if dataset_id:
params["dataset_id"] = str(dataset_id)
response = self.request("GET", "/user-data/credentials", params=params)
return UserDataCredentials(**response.json())

# Container registry access
Expand Down Expand Up @@ -917,8 +930,8 @@ def delete_workspace(self, workspace_id: str | UUID) -> None:

def create_dataset(
self,
request: DatasetUploadRequest,
) -> DatasetUploadResponse:
request: CreateDatasetRequest,
) -> CreateDatasetResponse:
"""
Creates a new dataset.

Expand All @@ -929,23 +942,22 @@ def create_dataset(
DatasetUploadResponse: The dataset upload response object.
"""

payload: dict[str, t.Any] = request.model_dump()

response = self.request("POST", "/datasets/upload", json_data=payload)
response = self.request("POST", "/datasets", json_data=request.model_dump())

return DatasetUploadResponse.model_validate(response.json())
return CreateDatasetResponse(**response.json())

def upload_complete(self, request: DatasetUploadComplete) -> None:
def upload_complete(self, request: DatasetUploadCompleteRequest) -> DatasetMetadata:
"""
Marks a dataset upload as complete.

Args:
request (DatasetUploadComplete): The dataset upload completion request object.
"""

payload: dict[str, t.Any] = request

self.request("POST", "/datasets/upload/complete", json_data=payload)
response = self.request(
"POST", "/datasets/upload-complete", json_data=request.model_dump(mode="json")
)
return DatasetMetadata(**response.json())

def download_dataset(self, request: DatasetDownloadRequest) -> DatasetDownloadResponse:
"""
Expand All @@ -959,7 +971,7 @@ def download_dataset(self, request: DatasetDownloadRequest) -> DatasetDownloadRe
"""
response = self.request(
"GET",
f"/datasets/{request.dataset_uri}/download/?version={request.version}",
f"/datasets/{request.dataset_uri}/download?version={request.version}",
)

return DatasetDownloadResponse.model_validate(response.json())
Expand All @@ -983,7 +995,7 @@ def get_dataset(
def update_dataset(
self,
dataset_id_or_key: str | UUID,
dataset: DatasetUploadRequest,
dataset: CreateDatasetRequest,
) -> DatasetMetadata:
"""
Updates an existing dataset.
Expand All @@ -1000,3 +1012,13 @@ def update_dataset(

response = self.request("PUT", f"/datasets/{dataset_id_or_key}", json_data=payload)
return DatasetMetadata(**response.json())

def delete_dataset(self, dataset_id_or_key: str | UUID) -> None:
"""
Deletes a specific dataset.

Args:
dataset_id_or_key (str | UUID): The dataset identifier.
"""

self.request("DELETE", f"/datasets/{dataset_id_or_key}")
Loading
Loading