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 .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.2.0-alpha.34"
".": "0.2.0-alpha.35"
}
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,19 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## 0.2.0-alpha.35 (2024-11-04)

Full Changelog: [v0.2.0-alpha.34...v0.2.0-alpha.35](https://github.com/openlayer-ai/openlayer-python/compare/v0.2.0-alpha.34...v0.2.0-alpha.35)

### Features

* feat(data): add function to push a commit to the platform ([7b5a29e](https://github.com/openlayer-ai/openlayer-python/commit/7b5a29e7622fec7185b6eb9eec705ac298888d5e))


### Chores

* **internal:** version bump ([#370](https://github.com/openlayer-ai/openlayer-python/issues/370)) ([5b3bd38](https://github.com/openlayer-ai/openlayer-python/commit/5b3bd3887d10dea9371ea1c7e417e32e047a7462))

## 0.2.0-alpha.34 (2024-11-01)

Full Changelog: [v0.2.0-alpha.33...v0.2.0-alpha.34](https://github.com/openlayer-ai/openlayer-python/compare/v0.2.0-alpha.33...v0.2.0-alpha.34)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "openlayer"
version = "0.2.0-alpha.34"
version = "0.2.0-alpha.35"
description = "The official Python library for the openlayer API"
dynamic = ["readme"]
license = "Apache-2.0"
Expand Down
5 changes: 5 additions & 0 deletions src/openlayer/_utils/_transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,11 @@ def _transform_recursive(
# Iterable[T]
or (is_iterable_type(stripped_type) and is_iterable(data) and not isinstance(data, str))
):
# dicts are technically iterable, but it is an iterable on the keys of the dict and is not usually
# intended as an iterable, so we don't transform it.
if isinstance(data, dict):
return cast(object, data)

inner_type = extract_type_arg(stripped_type, 0)
return [_transform_recursive(d, annotation=annotation, inner_type=inner_type) for d in data]

Expand Down
2 changes: 1 addition & 1 deletion src/openlayer/_version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

__title__ = "openlayer"
__version__ = "0.2.0-alpha.34" # x-release-please-version
__version__ = "0.2.0-alpha.35" # x-release-please-version
48 changes: 48 additions & 0 deletions src/openlayer/lib/data/commit.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
"""Pushes a commit to the Openlayer platform."""

import os
import tarfile
import tempfile
from typing import Optional


from ... import Openlayer
from . import StorageType, _upload


def push(
client: Openlayer,
directory: str,
project_id: str,
message: str = "New commit",
storage_type: Optional[StorageType] = None,
) -> None:
"""Push a new commit to the Openlayer platform.

This is equivalent to running `openlayer push` from the Openlayer CLI."""
if not os.path.exists(directory):
raise ValueError(f"Directory {directory} does not exist.")

with tempfile.TemporaryDirectory() as tmp_dir:
tar_file_path = os.path.join(tmp_dir, "bundle.tar")
with tarfile.open(tar_file_path, mode="w") as tar:
tar.add(directory, arcname=os.path.basename(directory))

# Upload tar storage
uploader = _upload.Uploader(client, storage_type)
object_name = "bundle.tar"
presigned_url_response = client.storage.presigned_url.create(
object_name=object_name,
)
uploader.upload(
file_path=tar_file_path,
object_name=object_name,
presigned_url_response=presigned_url_response,
)

# Create the project version (commit)
client.projects.commits.create(
project_id=project_id,
commit={"message": message, "source": "cli"},
storage_uri=presigned_url_response.storage_uri,
)