Skip to content

Commit

Permalink
feat(api): manual updates (#360)
Browse files Browse the repository at this point in the history
  • Loading branch information
Stainless Bot authored and stainless-app[bot] committed Oct 31, 2024
1 parent f1c1ea6 commit 2588250
Show file tree
Hide file tree
Showing 34 changed files with 1,072 additions and 139 deletions.
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.31"
}
}
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
configured_endpoints: 13
configured_endpoints: 14
52 changes: 28 additions & 24 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@

### With Rye

We use [Rye](https://rye.astral.sh/) to manage dependencies so we highly recommend [installing it](https://rye.astral.sh/guide/installation/) as it will automatically provision a Python environment with the expected Python version.
We use [Rye](https://rye.astral.sh/) to manage dependencies because it will automatically provision a Python environment with the expected Python version. To set it up, run:

After installing Rye, you'll just have to run this command:
```sh
$ ./scripts/bootstrap
```

Or [install Rye manually](https://rye.astral.sh/guide/installation/) and run:

```sh
$ rye sync --all-features
Expand All @@ -31,25 +35,25 @@ $ pip install -r requirements-dev.lock

## Modifying/Adding code

Most of the SDK is generated code, and any modified code will be overridden on the next generation. The
`src/openlayer/lib/` and `examples/` directories are exceptions and will never be overridden.
Most of the SDK is generated code. Modifications to code will be persisted between generations, but may
result in merge conflicts between manual patches and changes from the generator. The generator will never
modify the contents of the `src/openlayer/lib/` and `examples/` directories.

## Adding and running examples

All files in the `examples/` directory are not modified by the Stainless generator and can be freely edited or
added to.
All files in the `examples/` directory are not modified by the generator and can be freely edited or added to.

```bash
```py
# add an example to examples/<your-example>.py

#!/usr/bin/env -S rye run python
```

```
chmod +x examples/<your-example>.py
```sh
$ chmod +x examples/<your-example>.py
# run the example against your api
./examples/<your-example>.py
$ ./examples/<your-example>.py
```

## Using the repository from source
Expand All @@ -58,8 +62,8 @@ If you’d like to use the repository from source, you can either install from g

To install via git:

```bash
pip install git+ssh://git@github.com/openlayer-ai/openlayer-python.git
```sh
$ pip install git+ssh://git@github.com/openlayer-ai/openlayer-python.git
```

Alternatively, you can build from source and install the wheel file:
Expand All @@ -68,29 +72,29 @@ Building this package will create two files in the `dist/` directory, a `.tar.gz

To create a distributable version of the library, all you have to do is run this command:

```bash
rye build
```sh
$ rye build
# or
python -m build
$ python -m build
```

Then to install:

```sh
pip install ./path-to-wheel-file.whl
$ pip install ./path-to-wheel-file.whl
```

## Running tests

Most tests require you to [set up a mock server](https://github.com/stoplightio/prism) against the OpenAPI spec to run the tests.

```bash
```sh
# you will need npm installed
npx prism mock path/to/your/openapi.yml
$ npx prism mock path/to/your/openapi.yml
```

```bash
rye run pytest
```sh
$ ./scripts/test
```

## Linting and formatting
Expand All @@ -100,14 +104,14 @@ This repository uses [ruff](https://github.com/astral-sh/ruff) and

To lint:

```bash
rye run lint
```sh
$ ./scripts/lint
```

To format and fix all ruff issues automatically:

```bash
rye run format
```sh
$ ./scripts/format
```

## Publishing and releases
Expand Down
37 changes: 26 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ client = Openlayer(
api_key=os.environ.get("OPENLAYER_API_KEY"),
)

data_stream_response = client.inference_pipelines.data.stream(
response = client.inference_pipelines.data.stream(
inference_pipeline_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
config={
"input_variable_names": ["user_query"],
Expand All @@ -47,11 +47,11 @@ data_stream_response = client.inference_pipelines.data.stream(
"output": "42",
"tokens": 7,
"cost": 0.02,
"timestamp": 1620000000,
"timestamp": 1610000000,
}
],
)
print(data_stream_response.success)
print(response.success)
```

While you can provide an `api_key` keyword argument,
Expand All @@ -75,7 +75,7 @@ client = AsyncOpenlayer(


async def main() -> None:
data_stream_response = await client.inference_pipelines.data.stream(
response = await client.inference_pipelines.data.stream(
inference_pipeline_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
config={
"input_variable_names": ["user_query"],
Expand All @@ -90,11 +90,11 @@ async def main() -> None:
"output": "42",
"tokens": 7,
"cost": 0.02,
"timestamp": 1620000000,
"timestamp": 1610000000,
}
],
)
print(data_stream_response.success)
print(response.success)


asyncio.run(main())
Expand Down Expand Up @@ -142,7 +142,7 @@ try:
"output": "42",
"tokens": 7,
"cost": 0.02,
"timestamp": 1620000000,
"timestamp": 1610000000,
}
],
)
Expand Down Expand Up @@ -203,7 +203,7 @@ client.with_options(max_retries=5).inference_pipelines.data.stream(
"output": "42",
"tokens": 7,
"cost": 0.02,
"timestamp": 1620000000,
"timestamp": 1610000000,
}
],
)
Expand Down Expand Up @@ -244,7 +244,7 @@ client.with_options(timeout=5.0).inference_pipelines.data.stream(
"output": "42",
"tokens": 7,
"cost": 0.02,
"timestamp": 1620000000,
"timestamp": 1610000000,
}
],
)
Expand Down Expand Up @@ -300,7 +300,7 @@ response = client.inference_pipelines.data.with_raw_response.stream(
"output": "42",
"tokens": 7,
"cost": 0.02,
"timestamp": 1620000000,
"timestamp": 1610000000,
}],
)
print(response.headers.get('X-My-Header'))
Expand Down Expand Up @@ -335,7 +335,7 @@ with client.inference_pipelines.data.with_streaming_response.stream(
"output": "42",
"tokens": 7,
"cost": 0.02,
"timestamp": 1620000000,
"timestamp": 1610000000,
}
],
) as response:
Expand Down Expand Up @@ -425,6 +425,21 @@ We take backwards-compatibility seriously and work hard to ensure you can rely o

We are keen for your feedback; please open an [issue](https://www.github.com/openlayer-ai/openlayer-python/issues) with questions, bugs, or suggestions.

### Determining the installed version

If you've upgraded to the latest version but aren't seeing any new features you were expecting then your python environment is likely still using an older version.

You can determine the version that is being used at runtime with:

```py
import openlayer
print(openlayer.__version__)
```

## Requirements

Python 3.7 or higher.

## Contributing

See [the contributing documentation](./CONTRIBUTING.md).
10 changes: 10 additions & 0 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,16 @@ Methods:

# Commits

Types:

```python
from openlayer.types import CommitCreateResponse
```

Methods:

- <code title="post /projects/{projectId}/versions">client.commits.<a href="./src/openlayer/resources/commits/commits.py">create</a>(project_id, \*\*<a href="src/openlayer/types/commit_create_params.py">params</a>) -> <a href="./src/openlayer/types/commit_create_response.py">CommitCreateResponse</a></code>

## TestResults

Types:
Expand Down
11 changes: 2 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ classifiers = [
"License :: OSI Approved :: Apache Software License"
]



[project.urls]
Homepage = "https://github.com/openlayer-ai/openlayer-python"
Repository = "https://github.com/openlayer-ai/openlayer-python"
Expand All @@ -62,19 +60,18 @@ dev-dependencies = [
"dirty-equals>=0.6.0",
"importlib-metadata>=6.7.0",
"rich>=13.7.1",

]

[tool.rye.scripts]
format = { chain = [
"format:ruff",
"format:docs",
"fix:ruff",
# run formatting again to fix any inconsistencies when imports are stripped
"format:ruff",
]}
"format:black" = "black ."
"format:docs" = "python scripts/utils/ruffen-docs.py README.md api.md"
"format:ruff" = "ruff format"
"format:isort" = "isort ."

"lint" = { chain = [
"check:ruff",
Expand Down Expand Up @@ -132,10 +129,6 @@ path = "README.md"
pattern = '\[(.+?)\]\(((?!https?://)\S+?)\)'
replacement = '[\1](https://github.com/openlayer-ai/openlayer-python/tree/main/\g<2>)'

[tool.black]
line-length = 120
target-version = ["py37"]

[tool.pytest.ini_options]
testpaths = ["tests"]
addopts = "--tb=short"
Expand Down
27 changes: 12 additions & 15 deletions requirements-dev.lock
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ anyio==4.4.0
# via openlayer
argcomplete==3.1.2
# via nox
attrs==23.1.0
# via pytest
certifi==2023.7.22
# via httpcore
# via httpx
Expand All @@ -28,8 +26,9 @@ distlib==0.3.7
# via virtualenv
distro==1.8.0
# via openlayer
exceptiongroup==1.1.3
exceptiongroup==1.2.2
# via anyio
# via pytest
filelock==3.12.4
# via virtualenv
h11==0.14.0
Expand All @@ -49,7 +48,7 @@ markdown-it-py==3.0.0
# via rich
mdurl==0.1.2
# via markdown-it-py
mypy==1.10.1
mypy==1.11.2
mypy-extensions==1.0.0
# via mypy
nodeenv==1.8.0
Expand All @@ -64,20 +63,18 @@ pandas==2.2.2
# via openlayer
platformdirs==3.11.0
# via virtualenv
pluggy==1.3.0
# via pytest
py==1.11.0
pluggy==1.5.0
# via pytest
pydantic==2.7.1
pydantic==2.9.2
# via openlayer
pydantic-core==2.18.2
pydantic-core==2.23.4
# via pydantic
pygments==2.18.0
# via rich
pyright==1.1.374
pytest==7.1.1
pyright==1.1.380
pytest==8.3.3
# via pytest-asyncio
pytest-asyncio==0.21.1
pytest-asyncio==0.24.0
python-dateutil==2.8.2
# via pandas
# via time-machine
Expand All @@ -86,7 +83,7 @@ pytz==2023.3.post1
# via pandas
respx==0.20.2
rich==13.7.1
ruff==0.5.6
ruff==0.6.9
setuptools==68.2.2
# via nodeenv
six==1.16.0
Expand All @@ -96,10 +93,10 @@ sniffio==1.3.0
# via httpx
# via openlayer
time-machine==2.9.0
tomli==2.0.1
tomli==2.0.2
# via mypy
# via pytest
typing-extensions==4.8.0
typing-extensions==4.12.2
# via anyio
# via mypy
# via openlayer
Expand Down
Loading

0 comments on commit 2588250

Please sign in to comment.