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: 0.1.0-beta.4 #99

Merged
merged 96 commits into from
Jan 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
96 commits
Select commit Hold shift + click to select a range
1b9edd9
feat(api): OpenAPI spec update via Stainless API (#97)
stainless-app[bot] Sep 30, 2024
b4b48c0
chore(internal): codegen related update (#98)
stainless-app[bot] Sep 30, 2024
e5cbcbd
codegen metadata
stainless-bot Oct 1, 2024
23e4233
feat(api): OpenAPI spec update via Stainless API (#100)
stainless-app[bot] Oct 4, 2024
b946911
chore(internal): codegen related update (#101)
stainless-app[bot] Oct 4, 2024
9cbc145
chore(internal): codegen related update (#102)
stainless-app[bot] Oct 4, 2024
2ed9f53
chore(internal): codegen related update (#103)
stainless-app[bot] Oct 4, 2024
2253e61
chore(internal): add support for parsing bool response content (#104)
stainless-app[bot] Oct 4, 2024
d53b0c0
feat(api): OpenAPI spec update via Stainless API (#105)
stainless-app[bot] Oct 7, 2024
465d868
fix(client): avoid OverflowError with very large retry counts (#106)
stainless-app[bot] Oct 7, 2024
8306ee7
chore: add repr to PageInfo class (#107)
stainless-app[bot] Oct 7, 2024
a58c149
feat(api): api update (#108)
stainless-app[bot] Oct 24, 2024
9e781b0
feat(api): api update (#109)
stainless-app[bot] Oct 29, 2024
5cb0771
chore: rebuild project due to codegen change (#110)
stainless-app[bot] Oct 30, 2024
008bd54
feat(api): api update (#111)
stainless-app[bot] Oct 31, 2024
086bed0
chore: rebuild project due to codegen change (#112)
stainless-app[bot] Nov 1, 2024
0973898
feat(api): api update (#113)
stainless-app[bot] Nov 1, 2024
d142e14
chore: rebuild project due to codegen change (#114)
stainless-app[bot] Nov 1, 2024
7b5ba26
chore: rebuild project due to codegen change (#115)
stainless-app[bot] Nov 2, 2024
c01f739
chore: rebuild project due to codegen change (#116)
stainless-app[bot] Nov 4, 2024
28ed14a
feat(api): api update (#117)
stainless-app[bot] Nov 4, 2024
35b2858
feat(api): api update (#118)
stainless-app[bot] Nov 5, 2024
2977ea1
feat(api): api update (#119)
stainless-app[bot] Nov 5, 2024
6d70b65
feat(api): api update (#120)
stainless-app[bot] Nov 6, 2024
78041e9
codegen metadata
stainless-bot Nov 8, 2024
6b0103b
codegen metadata
stainless-bot Nov 8, 2024
f5da454
chore: rebuild project due to codegen change (#121)
stainless-app[bot] Nov 12, 2024
1e76c7d
chore: rebuild project due to codegen change (#122)
stainless-app[bot] Nov 12, 2024
6e879af
feat(api): api update (#123)
stainless-app[bot] Nov 14, 2024
6b92d9c
feat(api): api update (#124)
stainless-app[bot] Nov 14, 2024
8ad959f
chore: rebuild project due to codegen change (#125)
stainless-app[bot] Nov 18, 2024
a864791
chore: rebuild project due to codegen change (#126)
stainless-app[bot] Nov 18, 2024
99f2b45
codegen metadata
stainless-bot Nov 20, 2024
aae43f9
codegen metadata
stainless-bot Nov 20, 2024
288a77f
chore(internal): fix compat model_dump method when warnings are passe…
stainless-app[bot] Nov 22, 2024
c6a4123
feat(api): api update (#128)
stainless-app[bot] Nov 22, 2024
670d5ab
docs: add info log level to readme (#129)
stainless-app[bot] Nov 25, 2024
9a3f84b
chore: remove now unused `cached-property` dep (#130)
stainless-app[bot] Nov 25, 2024
6f05ce1
codegen metadata
stainless-bot Nov 26, 2024
bf0c16e
feat(api): api update (#131)
stainless-app[bot] Nov 26, 2024
2917f6e
chore(internal): exclude mypy from running on tests (#132)
stainless-app[bot] Nov 27, 2024
5d8b9cc
fix(client): compat with new httpx 0.28.0 release (#133)
stainless-app[bot] Nov 28, 2024
e313f0a
chore(internal): bump pyright (#134)
stainless-app[bot] Dec 2, 2024
85f1025
chore: make the `Omit` type public (#135)
stainless-app[bot] Dec 4, 2024
30f51ae
feat(api): api update (#136)
stainless-app[bot] Dec 5, 2024
a3d6204
chore(internal): bump pydantic dependency (#137)
stainless-app[bot] Dec 9, 2024
f9c9290
docs(readme): fix http client proxies example (#138)
stainless-app[bot] Dec 9, 2024
6fcda79
feat(api): api update (#139)
stainless-app[bot] Dec 10, 2024
24f5bf0
chore(internal): bump pyright (#140)
stainless-app[bot] Dec 12, 2024
17c7ae6
chore(internal): add support for TypeAliasType (#141)
stainless-app[bot] Dec 12, 2024
3cf4086
chore(internal): remove some duplicated imports (#142)
stainless-app[bot] Dec 13, 2024
29abf00
chore(internal): updated imports (#143)
stainless-app[bot] Dec 13, 2024
63abf5d
feat(api): api update (#144)
stainless-app[bot] Dec 14, 2024
373b0bc
docs(readme): example snippet for client context manager (#145)
stainless-app[bot] Dec 16, 2024
7a35c26
chore(internal): fix some typos (#146)
stainless-app[bot] Dec 17, 2024
3690360
feat(api): api update (#147)
stainless-app[bot] Dec 17, 2024
32d7dc0
codegen metadata
stainless-app[bot] Dec 18, 2024
0e22565
feat(api): api update (#148)
stainless-app[bot] Dec 20, 2024
c30e9bf
chore(internal): codegen related update (#149)
stainless-app[bot] Jan 1, 2025
d027800
feat(api): api update (#150)
stainless-app[bot] Jan 3, 2025
e5fde7c
chore: add missing isclass check (#151)
stainless-app[bot] Jan 6, 2025
337146f
chore(internal): bump httpx dependency (#152)
stainless-app[bot] Jan 7, 2025
1670196
codegen metadata
stainless-app[bot] Jan 7, 2025
f8f67e6
fix(client): only call .close() when needed (#153)
stainless-app[bot] Jan 7, 2025
d3c2f67
codegen metadata
stainless-app[bot] Jan 8, 2025
2fd0635
docs: fix typos (#154)
stainless-app[bot] Jan 8, 2025
bdfb2d0
chore(internal): codegen related update (#155)
stainless-app[bot] Jan 8, 2025
06e842b
feat(api): api update (#156)
stainless-app[bot] Jan 8, 2025
c185997
feat(api): api update (#157)
stainless-app[bot] Jan 9, 2025
f161f75
codegen metadata
stainless-app[bot] Jan 9, 2025
45e89f1
feat(api): api update (#158)
stainless-app[bot] Jan 9, 2025
b26b63b
fix: correctly handle deserialising `cls` fields (#159)
stainless-app[bot] Jan 10, 2025
bc8ff1a
codegen metadata
stainless-app[bot] Jan 10, 2025
368fd85
feat(api): api update (#160)
stainless-app[bot] Jan 10, 2025
109129d
feat(api): api update (#161)
stainless-app[bot] Jan 13, 2025
db5dc45
chore(internal): update deps (#162)
stainless-app[bot] Jan 14, 2025
f8eb0ab
feat(api): api update (#163)
stainless-app[bot] Jan 14, 2025
7985bb7
codegen metadata
stainless-app[bot] Jan 15, 2025
6a2460f
chore(internal): bump pyright dependency (#164)
stainless-app[bot] Jan 15, 2025
bdf7961
codegen metadata
stainless-app[bot] Jan 15, 2025
85e811d
codegen metadata
stainless-app[bot] Jan 16, 2025
7268df6
codegen metadata
stainless-app[bot] Jan 16, 2025
0ad8741
codegen metadata
stainless-app[bot] Jan 16, 2025
3a868c4
feat(api): api update (#165)
stainless-app[bot] Jan 17, 2025
e7ca427
feat(api): api update (#166)
stainless-app[bot] Jan 18, 2025
5afb7a8
docs(raw responses): fix duplicate `the` (#167)
stainless-app[bot] Jan 20, 2025
db126f2
fix(tests): make test_get_platform less flaky (#168)
stainless-app[bot] Jan 20, 2025
3136426
chore(internal): avoid pytest-asyncio deprecation warning (#169)
stainless-app[bot] Jan 20, 2025
20e89dc
chore(internal): minor style changes (#170)
stainless-app[bot] Jan 21, 2025
4389567
feat(api): api update (#171)
stainless-app[bot] Jan 21, 2025
b875199
codegen metadata
stainless-app[bot] Jan 22, 2025
338b30f
codegen metadata
stainless-app[bot] Jan 22, 2025
2d14bf3
codegen metadata
stainless-app[bot] Jan 22, 2025
986fa49
chore(internal): minor formatting changes (#172)
stainless-app[bot] Jan 23, 2025
fd3749c
release: 0.1.0-beta.4
stainless-app[bot] Jan 23, 2025
e3b62ca
Remove parse_datetime
keyworks Jan 25, 2025
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
3 changes: 1 addition & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ jobs:
lint:
name: lint
runs-on: ubuntu-latest


steps:
- uses: actions/checkout@v4
Expand All @@ -30,6 +29,7 @@ jobs:

- name: Run lints
run: ./scripts/lint

test:
name: test
runs-on: ubuntu-latest
Expand All @@ -50,4 +50,3 @@ jobs:

- name: Run tests
run: ./scripts/test

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.1.0-beta.3"
".": "0.1.0-beta.4"
}
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 91
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/metronome%2Fmetronome-c4ec65355a30c07306ddff2c4a97411c2eb631a878583ce8bdd876a4fe2a5c96.yml
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/metronome%2Fmetronome-d45fa7bea4d4904432df31863500afbad8207834d9857d1d4b37549ed4621e10.yml
94 changes: 94 additions & 0 deletions CHANGELOG.md

Large diffs are not rendered by default.

44 changes: 24 additions & 20 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 Down Expand Up @@ -39,17 +43,17 @@ modify the contents of the `src/metronome/lib/` and `examples/` directories.

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://[email protected]/Metronome-Industries/metronome-python.git
```sh
$ pip install git+ssh://[email protected]/Metronome-Industries/metronome-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
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright 2024 Metronome
Copyright 2025 Metronome

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
44 changes: 29 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

[![PyPI version](https://img.shields.io/pypi/v/metronome-sdk.svg)](https://pypi.org/project/metronome-sdk/)

The Metronome Python library provides convenient access to the Metronome REST API from any Python 3.7+
The Metronome Python library provides convenient access to the Metronome REST API from any Python 3.8+
application. The library includes type definitions for all request params and response fields,
and offers both synchronous and asynchronous clients powered by [httpx](https://github.com/encode/httpx).

Expand All @@ -30,8 +30,7 @@ import os
from metronome import Metronome

client = Metronome(
# This is the default and can be omitted
bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"),
bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted
)

client.usage.ingest(
Expand Down Expand Up @@ -61,8 +60,7 @@ import asyncio
from metronome import AsyncMetronome

client = AsyncMetronome(
# This is the default and can be omitted
bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"),
bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted
)


Expand Down Expand Up @@ -189,7 +187,7 @@ except metronome.APIStatusError as e:
print(e.response)
```

Error codes are as followed:
Error codes are as follows:

| Status Code | Error Type |
| ----------- | -------------------------- |
Expand Down Expand Up @@ -266,12 +264,14 @@ Note that requests that time out are [retried twice by default](#retries).

We use the standard library [`logging`](https://docs.python.org/3/library/logging.html) module.

You can enable logging by setting the environment variable `METRONOME_LOG` to `debug`.
You can enable logging by setting the environment variable `METRONOME_LOG` to `info`.

```shell
$ export METRONOME_LOG=debug
$ export METRONOME_LOG=info
```

Or to `debug` for more verbose logging.

### How to tell whether `None` means `null` or missing

In an API response, a field may be explicitly `null`, or missing entirely; in either case, its value is `None` in this library. You can differentiate the two cases with `.model_fields_set`:
Expand Down Expand Up @@ -334,8 +334,7 @@ If you need to access undocumented endpoints, params, or response properties, th
#### Undocumented endpoints

To make requests to undocumented endpoints, you can make requests using `client.get`, `client.post`, and other
http verbs. Options on the client will be respected (such as retries) will be respected when making this
request.
http verbs. Options on the client will be respected (such as retries) when making this request.

```py
import httpx
Expand Down Expand Up @@ -364,18 +363,19 @@ can also get all the extra fields on the Pydantic model as a dict with

You can directly override the [httpx client](https://www.python-httpx.org/api/#client) to customize it for your use case, including:

- Support for proxies
- Custom transports
- Support for [proxies](https://www.python-httpx.org/advanced/proxies/)
- Custom [transports](https://www.python-httpx.org/advanced/transports/)
- Additional [advanced](https://www.python-httpx.org/advanced/clients/) functionality

```python
import httpx
from metronome import Metronome, DefaultHttpxClient

client = Metronome(
# Or use the `METRONOME_BASE_URL` env var
base_url="http://my.test.server.example.com:8083",
http_client=DefaultHttpxClient(
proxies="http://my.test.proxy.example.com",
proxy="http://my.test.proxy.example.com",
transport=httpx.HTTPTransport(local_address="0.0.0.0"),
),
)
Expand All @@ -391,12 +391,22 @@ client.with_options(http_client=DefaultHttpxClient(...))

By default the library closes underlying HTTP connections whenever the client is [garbage collected](https://docs.python.org/3/reference/datamodel.html#object.__del__). You can manually close the client using the `.close()` method if desired, or with a context manager that closes when exiting.

```py
from metronome import Metronome

with Metronome() as client:
# make requests here
...

# HTTP client is now closed
```

## Versioning

This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:

1. Changes that only affect static types, without breaking runtime behavior.
2. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals)_.
2. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_
3. Changes that we do not expect to impact the vast majority of users in practice.

We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.
Expand All @@ -416,4 +426,8 @@ print(metronome.__version__)

## Requirements

Python 3.7 or higher.
Python 3.8 or higher.

## Contributing

See [the contributing documentation](./CONTRIBUTING.md).
Loading
Loading