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

Migrate from Poetry to uv #121

Merged
merged 9 commits into from
Sep 9, 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
21 changes: 11 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ on:
tags:
- "v*"

env:
PYTHON_VERSION: "3.8"
POETRY_VERSION: "1.5"

jobs:
lint:
name: Lint
Expand Down Expand Up @@ -53,9 +49,9 @@ jobs:
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
- run: pip install poetry==${{ env.POETRY_VERSION }}
- run: poetry install
- run: poetry run python -m pytest
- name: Install uv
uses: astral-sh/setup-uv@v2
- run: uv run pytest
env:
AXIOM_URL: ${{ secrets[matrix.url] }}
AXIOM_TOKEN: ${{ secrets[matrix.token] }}
Expand All @@ -69,8 +65,13 @@ jobs:
- test-integration
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v2
- uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- run: pip install poetry==${{ env.POETRY_VERSION }}
- run: poetry publish --build -u __token__ -p "${{ secrets.PYPI_TOKEN }}"
python-version-file: "pyproject.toml"
- run: uv build
- run: uvx twine upload dist/*
env:
TWINE_USERNAME: "__token__"
TWINE_PASSWORD: "${{ secrets.PYPI_TOKEN }}"
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,6 @@ poetry.lock
# Direnv
/.envrc
/.direnv

# UV lockfiles
uv.lock
17 changes: 7 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,19 @@ Otherwise create a personal token in [the Axiom settings](https://cloud.axiom.co
You can also configure the client using options passed to the client constructor:

```py
import axiom
import axiom_py

client = axiom.Client("<api token>", "<org id>")
client = axiom_py.Client("<api token>", "<org id>")
```

Create and use a client like this:

```py
import axiom
import axiom_py
import rfc3339
from datetime import datetime,timedelta

client = axiom.Client()
client = axiom_py.Client()

time = datetime.utcnow() - timedelta(hours=1)
time_formatted = rfc3339.format(time)
Expand All @@ -75,15 +75,12 @@ client.ingest_events(
client.query(r"['my-dataset'] | where foo == 'bar' | limit 100")
```

for more examples, check out the [examples](examples) directory.
for more examples, check out `examples.py`.

## Contributing

This project uses [Poetry](https://python-poetry.org) for dependecy management
and packaging, so make sure that this is installed (see [Poetry Installation](https://python-poetry.org/docs/#installation)).

Run `poetry install` to install dependencies and `poetry shell` to activate a
virtual environment.
This project uses [uv](https://docs.astral.sh/uv) for dependency management
and packaging, so make sure that this is installed.

## License

Expand Down
31 changes: 31 additions & 0 deletions examples.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from axiom_py import Client, DatasetCreateRequest


def main():
client = Client()
dataset_name = "my-dataset"

# List datasets
res = client.datasets.get_list()
for dataset in res:
print(dataset.name)

# Create a dataset
client.datasets.create(
DatasetCreateRequest(name=dataset_name, description="A description.")
)

# Ingest events
client.ingest_events(dataset_name, [{"foo": "bar"}])

# Query events
res = client.query(f"['{dataset_name}'] | where status == 500")
for match in res.matches:
print(match.data)

# Delete the dataset
client.datasets.delete(dataset_name)


if __name__ == "__main__":
main()
19 changes: 0 additions & 19 deletions examples/README.md

This file was deleted.

9 changes: 0 additions & 9 deletions examples/create_dataset.py

This file was deleted.

7 changes: 0 additions & 7 deletions examples/delete_dataset.py

This file was deleted.

8 changes: 0 additions & 8 deletions examples/ingest.py

This file was deleted.

8 changes: 0 additions & 8 deletions examples/list_datasets.py

This file was deleted.

26 changes: 0 additions & 26 deletions examples/main.py

This file was deleted.

19 changes: 0 additions & 19 deletions examples/pyproject.toml

This file was deleted.

10 changes: 0 additions & 10 deletions examples/query.py

This file was deleted.

19 changes: 0 additions & 19 deletions examples/query_legacy.py

This file was deleted.

52 changes: 27 additions & 25 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,34 +1,36 @@
[tool.poetry]
[project]
name = "axiom-py"
version = "0.5.0"
description = "Axiom API Python bindings."
authors = ["Axiom, Inc."]
license = "MIT"
packages = [
{ include = "axiom" },
description = "Official bindings for the Axiom API"
readme = "README.md"
requires-python = ">=3.8"
dependencies = [
"requests>=2.32.3",
"requests-toolbelt>=1.0.0",
"ujson>=5.10.0",
"dacite>=1.8.1",
"pyhumps>=3.8.0",
"ndjson>=0.3.1",
]
license = { file = "LICENSE" }

[tool.poetry.dependencies]
# urllib 3 has a breaking change in 2.0.0
urllib3 = "<3.0.0"
python = "^3.8"
requests = "^2.30.0"
requests-toolbelt = ">= 0.9.1, <1.1.0"
ujson = "^5.2.0"
dacite = "^1.6.0"
pyhumps = ">=1.6.1,<4.0.0"
ndjson = "^0.3.1"
rfc3339 = "^6.2"
iso8601 = ">=1.0.2,<3.0.0"

[tool.poetry.dev-dependencies]
pytest = "^8.2.1"
responses = "^0.25.0"
ruff = "^0.6.4"
[project.urls]
Homepage = "https://axiom.co"
Repository = "https://github.com/axiomhq/axiom-py.git"
Issues = "https://github.com/axiomhq/axiom-py/issues"

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.ruff]
line-length = 79 # PEP 8

[tool.uv]
dev-dependencies = [
"ruff>=0.6.4",
"pytest>=8.3.2",
"responses>=0.25.3",
"rfc3339>=6.2",
"iso8601>=1.0.2",
]
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion tests/test_annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import unittest
from logging import getLogger
from .helpers import get_random_name
from axiom import (
from axiom_py import (
Client,
DatasetCreateRequest,
AnnotationCreateRequest,
Expand Down
4 changes: 2 additions & 2 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from datetime import datetime, timedelta
from .helpers import get_random_name
from requests.exceptions import HTTPError
from axiom import (
from axiom_py import (
Client,
AplOptions,
AplResultFormat,
Expand All @@ -20,7 +20,7 @@
WrongQueryKindException,
DatasetCreateRequest,
)
from axiom.query import (
from axiom_py.query import (
QueryLegacy,
QueryOptions,
QueryKind,
Expand Down
2 changes: 1 addition & 1 deletion tests/test_datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from requests.exceptions import HTTPError
from datetime import timedelta
from .helpers import get_random_name
from axiom import (
from axiom_py import (
Client,
DatasetCreateRequest,
DatasetUpdateRequest,
Expand Down
4 changes: 2 additions & 2 deletions tests/test_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import logging
import unittest
from .helpers import get_random_name
from axiom import Client, DatasetCreateRequest
from axiom.logging import AxiomHandler
from axiom_py import Client, DatasetCreateRequest
from axiom_py.logging import AxiomHandler


class TestLogger(unittest.TestCase):
Expand Down