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

release: 1.40.7 #1650

Merged
merged 4 commits into from
Aug 15, 2024
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 @@
{
".": "1.40.6"
".": "1.40.7"
}
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# Changelog

## 1.40.7 (2024-08-15)

Full Changelog: [v1.40.6...v1.40.7](https://github.com/openai/openai-python/compare/v1.40.6...v1.40.7)

### Bug Fixes

* **cli/migrate:** change grit binaries download source ([#1649](https://github.com/openai/openai-python/issues/1649)) ([85e8935](https://github.com/openai/openai-python/commit/85e8935d9a123b92964d39a98334a975a06ab845))


### Chores

* **docs:** fix typo in example snippet ([4e83b57](https://github.com/openai/openai-python/commit/4e83b57ffbb64e1c98c19968557dc68a0b65d0b3))
* **internal:** use different 32bit detection method ([#1652](https://github.com/openai/openai-python/issues/1652)) ([5831af6](https://github.com/openai/openai-python/commit/5831af65048af2a5df9e3ea4a48b8fff2e66dd8c))

## 1.40.6 (2024-08-12)

Full Changelog: [v1.40.5...v1.40.6](https://github.com/openai/openai-python/compare/v1.40.5...v1.40.6)
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 = "openai"
version = "1.40.6"
version = "1.40.7"
description = "The official Python library for the openai API"
dynamic = ["readme"]
license = "Apache-2.0"
Expand Down
4 changes: 2 additions & 2 deletions src/openai/_base_client.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

import sys
import json
import time
import uuid
Expand Down Expand Up @@ -2012,7 +2013,6 @@ def get_python_version() -> str:

def get_architecture() -> Arch:
try:
python_bitness, _ = platform.architecture()
machine = platform.machine().lower()
except Exception:
return "unknown"
Expand All @@ -2028,7 +2028,7 @@ def get_architecture() -> Arch:
return "x64"

# TODO: untested
if python_bitness == "32bit":
if sys.maxsize <= 2**32:
return "x32"

if machine:
Expand Down
2 changes: 1 addition & 1 deletion src/openai/_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__ = "openai"
__version__ = "1.40.6" # x-release-please-version
__version__ = "1.40.7" # x-release-please-version
66 changes: 23 additions & 43 deletions src/openai/cli/_tools/migrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import os
import sys
import json
import shutil
import tarfile
import platform
Expand Down Expand Up @@ -85,7 +84,9 @@ def install() -> Path:
if sys.platform == "win32":
raise CLIError("Windows is not supported yet in the migration CLI")

platform = "macos" if sys.platform == "darwin" else "linux"
_debug("Using Grit installer from GitHub")

platform = "apple-darwin" if sys.platform == "darwin" else "unknown-linux-gnu"

dir_name = _cache_dir() / "openai-python"
install_dir = dir_name / ".install"
Expand All @@ -109,27 +110,14 @@ def install() -> Path:
arch = _get_arch()
_debug(f"Using architecture {arch}")

file_name = f"marzano-{platform}-{arch}"
meta_url = f"https://api.keygen.sh/v1/accounts/{KEYGEN_ACCOUNT}/artifacts/{file_name}"
file_name = f"marzano-{arch}-{platform}"
download_url = f"https://github.com/getgrit/gritql/releases/latest/download/{file_name}.tar.gz"

sys.stdout.write(f"Retrieving Grit CLI metadata from {meta_url}\n")
sys.stdout.write(f"Downloading Grit CLI from {download_url}\n")
with httpx.Client() as client:
response = client.get(meta_url) # pyright: ignore[reportUnknownMemberType]

data = response.json()
errors = data.get("errors")
if errors:
for error in errors:
sys.stdout.write(f"{error}\n")

raise CLIError("Could not locate Grit CLI binary - see above errors")

write_manifest(install_dir, data["data"]["relationships"]["release"]["data"]["id"])

link = data["data"]["links"]["redirect"]
_debug(f"Redirect URL {link}")

download_response = client.get(link) # pyright: ignore[reportUnknownMemberType]
download_response = client.get(download_url, follow_redirects=True)
if download_response.status_code != 200:
raise CLIError(f"Failed to download Grit CLI from {download_url}")
with open(temp_file, "wb") as file:
for chunk in download_response.iter_bytes():
file.write(chunk)
Expand All @@ -143,8 +131,7 @@ def install() -> Path:
else:
archive.extractall(unpacked_dir)

for item in unpacked_dir.iterdir():
item.rename(target_dir / item.name)
_move_files_recursively(unpacked_dir, target_dir)

shutil.rmtree(unpacked_dir)
os.remove(temp_file)
Expand All @@ -155,30 +142,23 @@ def install() -> Path:
return target_path


def _move_files_recursively(source_dir: Path, target_dir: Path) -> None:
for item in source_dir.iterdir():
if item.is_file():
item.rename(target_dir / item.name)
elif item.is_dir():
_move_files_recursively(item, target_dir)


def _get_arch() -> str:
architecture = platform.machine().lower()

# Map the architecture names to Node.js equivalents
# Map the architecture names to Grit equivalents
arch_map = {
"x86_64": "x64",
"amd64": "x64",
"armv7l": "arm",
"aarch64": "arm64",
"x86_64": "x86_64",
"amd64": "x86_64",
"armv7l": "aarch64",
"arm64": "aarch64",
}

return arch_map.get(architecture, architecture)


def write_manifest(install_path: Path, release: str) -> None:
manifest = {
"installPath": str(install_path),
"binaries": {
"marzano": {
"name": "marzano",
"release": release,
},
},
}
manifest_path = Path(install_path) / "manifests.json"
with open(manifest_path, "w") as f:
json.dump(manifest, f, indent=2)
4 changes: 2 additions & 2 deletions src/openai/resources/beta/chat/completions.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def stream(
) as stream:
for event in stream:
if event.type == "content.delta":
print(event.content, flush=True, end="")
print(event.delta, flush=True, end="")
```

When the context manager is entered, a `ChatCompletionStream` instance is returned which, like `.create(stream=True)` is an iterator. The full list of events that are yielded by the iterator are outlined in [these docs](https://github.com/openai/openai-python/blob/main/helpers.md#chat-completions-events).
Expand Down Expand Up @@ -404,7 +404,7 @@ def stream(
) as stream:
async for event in stream:
if event.type == "content.delta":
print(event.content, flush=True, end="")
print(event.delta, flush=True, end="")
```

When the context manager is entered, an `AsyncChatCompletionStream` instance is returned which, like `.create(stream=True)` is an async iterator. The full list of events that are yielded by the iterator are outlined in [these docs](https://github.com/openai/openai-python/blob/main/helpers.md#chat-completions-events).
Expand Down