Compare commits

..

11 Commits

Author SHA1 Message Date
github-actions[bot] be19185503 chore: version packages (#954)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-10-03 20:14:04 -04:00
Adrian Lyjak 7571b0d6c4 Missed some things again with tag fixes (#955)
guh
2025-10-03 20:12:53 -04:00
Adrian Lyjak ad6734bf80 fixup tagging more better (#953)
* fix: correct private field type in py/package.json to be recognized by pnpm

* use packages more directly, make public

* add bump

* fix crash
2025-10-03 19:53:57 -04:00
github-actions[bot] 9ec2a8322e chore: version packages (#952) 2025-10-03 15:11:14 -06:00
Logan 51011b9f30 fix changeset harder (#951) 2025-10-03 15:09:58 -06:00
Logan 09805f9e15 swap changesets (#949) 2025-10-03 15:06:00 -06:00
Adrian Lyjak 8ced6f6eab fix: explicitly tag. I thought the action did this (#948) 2025-10-03 16:59:41 -04:00
Preston Carlson 081ddeca34 Escaping dollar signs in md output when running in a jupyter notebook (#945) 2025-10-03 14:52:26 -06:00
Adrian Lyjak 2460908789 Disable npm release (#946) 2025-10-03 16:13:16 -04:00
Adrian Lyjak c226d6a54c Fix more bugs in publishing (#944) 2025-10-03 11:16:43 -04:00
Adrian Lyjak 5d4c682eb2 fix: theres just one publish token (#943) 2025-10-03 10:56:10 -04:00
13 changed files with 254 additions and 100 deletions
+1 -1
View File
@@ -8,7 +8,7 @@
"scripts": {
"pre-commit-version": "pnpm changeset",
"version": "./scripts/changeset-version.py version",
"publish": "./scripts/changeset-version.py publish"
"publish": "./scripts/changeset-version.py publish --no-js --tag"
},
"devDependencies": {
"prettier": "^3.6.2",
+15 -1
View File
@@ -21,7 +21,21 @@ importers:
specifier: ^3.6.2
version: 3.6.2
py: {}
py:
devDependencies:
changesets:
specifier: ^1.0.2
version: 1.0.2
py/llama_parse:
dependencies:
llama-cloud-services-py:
specifier: workspace:*
version: link:..
devDependencies:
changesets:
specifier: ^1.0.2
version: 1.0.2
ts/e2e-tests:
devDependencies:
+1
View File
@@ -1,3 +1,4 @@
packages:
- "ts/*"
- "py"
- "py/*"
+12
View File
@@ -1,5 +1,17 @@
# llama-cloud-services-py
## 0.6.72
### Patch Changes
- ad6734b: Fixup and test versioning
## 0.6.71
### Patch Changes
- 51011b9: Escape dollar signs in jupyter notebooks
## 0.6.70
### Patch Changes
+35 -6
View File
@@ -4,7 +4,10 @@ import re
from pydantic import BaseModel, Field, SerializeAsAny
from typing import Dict, Any, List, Optional
from llama_cloud_services.parse.utils import make_api_request
from llama_cloud_services.parse.utils import (
make_api_request,
is_jupyter,
)
from llama_index.core.async_utils import asyncio_run
from llama_index.core.schema import Document, ImageDocument, ImageNode, TextNode
@@ -258,6 +261,24 @@ class JobResult(BaseModel):
documents = await self.aget_text_documents(split_by_page)
return [TextNode(text=doc.text, metadata=doc.metadata) for doc in documents]
def _format_markdown_for_notebook(self, text: Optional[str]) -> Optional[str]:
"""Format markdown text for Jupyter notebook display by escaping dollar signs."""
if text is None:
return None
def escape_dollar_signs(text: str) -> str:
"""Escape dollar signs in text to prevent Jupyter from interpreting them as LaTeX.
Args:
text: The text to escape
Returns:
Text with dollar signs escaped
"""
return text.replace("$", r"\$")
return escape_dollar_signs(text)
def get_markdown_documents(self, split_by_page: bool = False) -> List[Document]:
"""
Get the markdown documents from the job.
@@ -268,17 +289,22 @@ class JobResult(BaseModel):
if split_by_page:
return [
Document(
text=page.md,
text=self._format_markdown_for_notebook(page.md)
if is_jupyter()
else page.md,
metadata={"page_number": page.page, "file_name": self.file_name},
)
for page in self.pages
]
else:
text = self._page_separator.join(
[page.md if page.md is not None else "" for page in self.pages]
)
return [
Document(
text=self._page_separator.join(
[page.md if page.md is not None else "" for page in self.pages]
),
text=self._format_markdown_for_notebook(text)
if is_jupyter()
else text,
metadata={"file_name": self.file_name},
)
]
@@ -328,7 +354,10 @@ class JobResult(BaseModel):
"""
url = f"{self._base_url}/api/v1/parsing/job/{self.job_id}/result/raw/markdown"
response = await make_api_request(self._client, "GET", url)
return response.content.decode("utf-8")
markdown = response.content.decode("utf-8")
return (
self._format_markdown_for_notebook(markdown) if is_jupyter() else markdown
)
def get_text(self) -> str:
"""
+12
View File
@@ -1,3 +1,4 @@
import functools
import httpx
import itertools
import logging
@@ -356,6 +357,17 @@ def partition_pages(
return
@functools.lru_cache(maxsize=1)
def is_jupyter() -> bool:
"""Check if we're running in a Jupyter environment."""
try:
from IPython import get_ipython
return get_ipython().__class__.__name__ == "ZMQInteractiveShell"
except (ImportError, AttributeError):
return False
def extract_tables_from_json_results(
json_results: List[dict], download_path: str
) -> List[str]:
+8
View File
@@ -0,0 +1,8 @@
# llama_parse
## 0.6.72
### Patch Changes
- Updated dependencies [ad6734b]
- llama-cloud-services-py@0.6.72
+20
View File
@@ -0,0 +1,20 @@
{
"name": "llama_parse",
"version": "0.6.72",
"description": "",
"main": "index.js",
"private": false,
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"dependencies": {
"llama-cloud-services-py": "workspace:*"
},
"keywords": [],
"author": "",
"license": "ISC",
"packageManager": "pnpm@10.11.1",
"devDependencies": {
"changesets": "^1.0.2"
}
}
+2 -2
View File
@@ -11,13 +11,13 @@ dev = [
[project]
name = "llama-parse"
version = "0.6.70"
version = "0.6.72"
description = "Parse files into RAG-Optimized formats."
authors = [{name = "Logan Markewich", email = "logan@llamaindex.ai"}]
requires-python = ">=3.9,<4.0"
readme = "README.md"
license = "MIT"
dependencies = ["llama-cloud-services>=0.6.70"]
dependencies = ["llama-cloud-services>=0.6.72"]
[project.scripts]
llama-parse = "llama_parse.cli.main:parse"
+6 -3
View File
@@ -1,7 +1,10 @@
{
"name": "llama-cloud-services-py",
"version": "0.6.70",
"private": "true",
"version": "0.6.72",
"private": false,
"license": "MIT",
"scripts": {}
"scripts": {},
"devDependencies": {
"changesets": "^1.0.2"
}
}
+1 -1
View File
@@ -19,7 +19,7 @@ dev = [
[project]
name = "llama-cloud-services"
version = "0.6.70"
version = "0.6.72"
description = "Tailored SDK clients for LlamaCloud services."
authors = [{name = "Logan Markewich", email = "logan@runllama.ai"}]
requires-python = ">=3.9,<4.0"
Generated
+2 -2
View File
@@ -1,5 +1,5 @@
version = 1
revision = 2
revision = 3
requires-python = ">=3.9, <4.0"
resolution-markers = [
"python_full_version >= '3.14'",
@@ -1596,7 +1596,7 @@ wheels = [
[[package]]
name = "llama-cloud-services"
version = "0.6.69"
version = "0.6.70"
source = { editable = "." }
dependencies = [
{ name = "click", version = "8.1.8", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.10'" },
+139 -84
View File
@@ -12,14 +12,15 @@ There's 2 things this does:
"""
from dataclasses import dataclass
import json
import os
import subprocess
import sys
from pathlib import Path
from typing import List
from typing import Any, List, cast
import urllib.request
import urllib.error
import re
import click
import tomlkit
@@ -27,54 +28,109 @@ from packaging.version import Version
def _run_command(
cmd: List[str], check: bool = True, capture: bool = True, cwd: Path | None = None
) -> subprocess.CompletedProcess:
"""Run a command and return the result."""
return subprocess.run(
cmd, check=check, capture_output=capture, text=True, cwd=cwd or Path.cwd()
cmd: List[str], cwd: Path | None = None, env: dict[str, str] | None = None
) -> None:
"""Run a command, streaming output to the console, and raise on failure."""
subprocess.run(cmd, check=True, text=True, cwd=cwd or Path.cwd(), env=env)
def _run_and_capture(
cmd: List[str], cwd: Path | None = None, env: dict[str, str] | None = None
) -> str:
"""Run a command and return stdout as text, raising on failure."""
result = subprocess.run(
cmd,
check=True,
text=True,
cwd=cwd or Path.cwd(),
env=env,
capture_output=True,
)
return result.stdout
def update_python_versions(version: str) -> None:
"""llama-cloud-services and llama-parse share a version. llama-parse is just a silly sidecar that proxies to llama-cloud-services
for compatibility.
@dataclass
class Package:
name: str
version: str
path: Path
This function updates the version in both pyproject.toml files.
def python_package_name(self) -> str | None:
if "/py/" in str(self.path) or str(self.path).endswith("/py"):
return self.name.removesuffix("-py")
return None
def _get_pnpm_workspace_packages() -> list[Package]:
"""Return directories for all workspace packages from pnpm list JSON output."""
output = _run_and_capture(["pnpm", "list", "-r", "--depth=-1", "--json"])
data = cast(list[dict[str, Any]], json.loads(output))
packages: list[Package] = [
Package(name=data["name"], version=data["version"], path=Path(data["path"]))
for data in data
]
return packages
def _sync_package_version_with_pyproject(
package_dir: Path, packages: dict[str, Package], js_package_name: str
) -> None:
"""Sync version from package.json to pyproject.toml.
Returns True if pyproject was changed, else False.
"""
# Update main pyproject.toml
main_path = Path("py/pyproject.toml")
main_content = main_path.read_text()
main_doc = tomlkit.parse(main_content)
if main_doc["project"]["version"] != version:
click.echo(f"Updating llama-cloud-services version to {version}")
main_doc["project"]["version"] = version
main_path.write_text(tomlkit.dumps(main_doc))
pyproject_path = package_dir / "pyproject.toml"
if not pyproject_path.exists():
return
# Update llama_parse/pyproject.toml
parse_path = Path("py/llama_parse/pyproject.toml")
parse_content = parse_path.read_text()
parse_doc = tomlkit.parse(parse_content)
if parse_doc["project"]["version"] != version:
click.echo(f"Updating llama-parse version to {version}")
parse_doc["project"]["version"] = version
parse_path.write_text(tomlkit.dumps(parse_doc))
package_version = packages[js_package_name].version
py_doc = tomlkit.parse(pyproject_path.read_text())
# Update the dependency reference
dependencies = parse_doc["project"]["dependencies"]
for i, dep in enumerate(dependencies):
if isinstance(dep, str) and dep.startswith("llama-cloud-services"):
dependencies[i] = f"llama-cloud-services>={version}"
break
by_python_name = {
pkg.python_package_name(): pkg
for pkg in packages.values()
if pkg.python_package_name()
}
parse_path.write_text(tomlkit.dumps(parse_doc))
current_version = py_doc["project"]["version"]
assert isinstance(current_version, str)
click.echo(f"Updated Python packages to version {version}")
# update workspace dependency strings by replacing the first version after == or >=
deps = py_doc["project"]["dependencies"] or []
changed = False
for i, dep in enumerate(deps):
if not isinstance(dep, str):
continue
pkg = (cast(str, dep).split("==")[0]).split(">=")[0]
if pkg not in by_python_name:
continue
target_version = by_python_name[pkg].version
new_dep = re.sub(
r"(==|>=)\s*([0-9A-Za-z_.+-]+)",
lambda m: m.group(1) + target_version,
dep,
count=1,
)
if new_dep != dep:
deps[i] = new_dep
changed = True
if current_version != package_version:
py_doc["project"]["version"] = package_version
changed = True
if changed:
pyproject_path.write_text(tomlkit.dumps(py_doc))
click.echo(
f"Updated {pyproject_path} version to {package_version} and synced dependency specs"
)
def lock_python_dependencies() -> None:
"""Lock Python dependencies."""
try:
_run_command(["uv", "lock"], capture=False)
_run_command(["uv", "lock"])
click.echo("Locked Python dependencies")
except subprocess.CalledProcessError as e:
click.echo(f"Warning: Failed to lock Python dependencies: {e}", err=True)
@@ -88,57 +144,64 @@ def cli() -> None:
@cli.command()
def version() -> None:
"""Apply changeset versions, and propagate them to Python packages."""
# First, run changeset version to update all package.json files (including py/package.json)
_run_command(["npx", "@changesets/cli", "version"], capture=False, check=True)
"""Apply changeset versions, then sync versions for co-located JS/Py packages.
# Get the updated Python package version from py/package.json (updated by changesets)
py_package_path = Path("py/package.json")
if not py_package_path.exists():
click.echo("Python package.json not found", err=True)
sys.exit(1)
- Runs changesets to bump package.json versions.
- Discovers all workspace packages via pnpm.
- For any directory containing both package.json and pyproject.toml, and with
package.json private: false, set pyproject [project].version to match the JS version.
- If a pyproject is updated, run `uv sync` in that directory to update its lock file.
"""
# Ensure we're at the repo root
os.chdir(Path(__file__).parent.parent)
with open(py_package_path) as f:
py_package = json.load(f)
# First, run changeset version to update all package.json files
_run_command(["npx", "@changesets/cli", "version"])
new_version = py_package["version"]
# Update Python pyproject.toml files based on the package.json version
update_python_versions(new_version)
click.echo(f"Successfully propagated version {new_version} to all Python packages")
# Enumerate workspace packages and perform syncs
packages = _get_pnpm_workspace_packages()
version_map = {pkg.name: pkg for pkg in packages}
for pkg in packages:
_sync_package_version_with_pyproject(pkg.path, version_map, pkg.name)
@cli.command()
@click.option("--tag", is_flag=True, help="Tag the packages after publishing")
@click.option("--dry-run", is_flag=True, help="Dry run the publish")
def publish(tag: bool, dry_run: bool) -> None:
@click.option("--js/--no-js", default=True, help="Publish the js package")
@click.option("--py/--no-py", default=True, help="Publish the py package")
def publish(tag: bool, dry_run: bool, js: bool, py: bool) -> None:
"""Publish all packages."""
# move to the root
os.chdir(Path(__file__).parent.parent)
if not os.getenv("NPM_TOKEN"):
click.echo("NPM_TOKEN is not set, skipping publish", err=True)
raise click.Abort("No token set")
if not os.getenv("LLAMA_PARSE_PYPI_TOKEN"):
click.echo("LLAMA_PARSE_PYPI_TOKEN is not set, skipping publish", err=True)
raise click.Abort("No token set")
if js:
if not os.getenv("NPM_TOKEN"):
click.echo("NPM_TOKEN is not set, skipping publish", err=True)
raise click.Abort("No token set")
if py:
if not os.getenv("LLAMA_PARSE_PYPI_TOKEN"):
click.echo("LLAMA_PARSE_PYPI_TOKEN is not set, skipping publish", err=True)
raise click.Abort("No token set")
# not general script. Just checks each of the 2 packages to see if they need to be published.
maybe_publish_ts_package(dry_run)
maybe_publish_py_packages(dry_run)
if js:
maybe_publish_npm(dry_run)
if py:
maybe_publish_pypi(dry_run)
if tag:
if dry_run:
click.echo("Dry run, skipping tag. Would run:")
click.echo(" npx @changesets/cli tag")
click.echo(" git push --tags")
return
else:
_run_command(["npx", "@changesets/cli", "tag"], check=True, capture=True)
_run_command(["git", "push", "--tags"], check=True, capture=True)
# Let changesets create JS-related tags as usual
_run_command(["npx", "@changesets/cli", "tag"])
_run_command(["git", "push", "--tags"])
def maybe_publish_ts_package(dry_run: bool) -> None:
def maybe_publish_npm(dry_run: bool) -> None:
"""Publish the ts package if it needs to be published."""
target_dir = Path("ts/llama_cloud_services")
ts_path_package = target_dir / "package.json"
@@ -146,10 +209,11 @@ def maybe_publish_ts_package(dry_run: bool) -> None:
version = package_json["version"]
# Check if this version is already published on npm
result = _run_command(
result = subprocess.run(
["npm", "view", "llama-cloud-services", "versions", "--json"],
check=True,
capture=True,
capture_output=True,
text=True,
cwd=target_dir,
)
@@ -159,20 +223,18 @@ def maybe_publish_ts_package(dry_run: bool) -> None:
f"npm package llama-cloud-services@{version} already published, skipping"
)
return
click.echo(f"Publishing llama-cloud-services@{version}")
click.echo(f"Publishing npm package llama-cloud-services@{version}")
# defer to the package.json publish script
if dry_run:
click.echo("Dry run, skipping publish. Would run:")
click.echo(" pnpm run publish")
return
else:
output = _run_command(
["pnpm", "runpublish"], check=True, capture=True, cwd=target_dir
)
click.echo(output.stdout)
_run_command(["pnpm", "run", "build"], cwd=target_dir)
_run_command(["pnpm", "publish"], cwd=target_dir)
def maybe_publish_py_packages(dry_run: bool) -> None:
def maybe_publish_pypi(dry_run: bool) -> None:
"""Publish the py packages if they need to be published."""
for pyproject in list(Path("py").glob("*/pyproject.toml")) + [
Path("py/pyproject.toml")
@@ -181,7 +243,7 @@ def maybe_publish_py_packages(dry_run: bool) -> None:
if is_published(name, version):
click.echo(f"PyPI package {name}@{version} already published, skipping")
continue
click.echo(f"Publishing {name}@{version}")
click.echo(f"Publishing PyPI package {name}@{version}")
# Use different tokens for different packages
env = os.environ.copy()
@@ -192,18 +254,11 @@ def maybe_publish_py_packages(dry_run: bool) -> None:
click.echo(
f"Dry run, skipping publish. Would run with publish token {summary}:"
)
click.echo(" uv publish --dry-run")
return
click.echo(" uv build")
click.echo(" uv publish")
else:
result = subprocess.run(
["uv", "publish"],
check=True,
capture_output=True,
text=True,
cwd=pyproject.parent,
env=env,
)
click.echo(result.stdout)
_run_command(["uv", "build"], cwd=pyproject.parent)
_run_command(["uv", "publish"], cwd=pyproject.parent, env=env)
def current_version(pyproject: Path) -> tuple[str, str]: