Skip to content

Commit b5f78d9

Browse files
committed
Added docs and tasks
1 parent d43c81d commit b5f78d9

File tree

6 files changed

+138
-359
lines changed

6 files changed

+138
-359
lines changed

.env.example

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# For e2e tests:
2+
ENGINE_CONNECTION_STRING= # Format: https://<cluster_name>.<region>.kusto.windows.net
3+
DM_CONNECTION_STRING= # Optional - if not set, will infer from ENGINE_CONNECTION_STRING. Format: https://ingest-<cluster_name>.<region>.kusto.windows.net
4+
TEST_DATABASE=
5+
6+
# For credential tests:
7+
8+
# app key provider:
9+
AZURE_CLIENT_ID=
10+
AZURE_CLIENT_SECRET=
11+
AZURE_TENANT_ID=
12+
# certificate provider:
13+
CERT_THUMBPRINT=
14+
CERT_PUBLIC_CERT_PATH=
15+
CERT_PEM_KEY_PATH=
16+
# managed identity provider:
17+
MSI_OBJECT_ID=
18+
MSI_CLIENT_ID=
19+
# user password provider:
20+
USER_NAME=
21+
USER_PASS=
22+
USER_AUTH_ID=

.github/workflows/build.yml

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,27 +35,25 @@ jobs:
3535
with:
3636
python-version: ${{ matrix.python-version }}
3737
enable-cache: true
38-
- name: Install the project
39-
run: uv sync --locked --all-extras --dev
4038
- name: EtoE Test with pytest
4139
env:
4240
TEST_DATABASE: ${{ secrets.TEST_DATABASE }}
4341
TEST_BLOB: ${{ secrets.TEST_BLOB }}
4442
ENGINE_CONNECTION_STRING: ${{ secrets.ENGINE_CONNECTION_STRING }}
4543
APPLICATION_INSIGHTS_ENGINE_CONNECTION_STRING: https://ade.applicationinsights.io/subscriptions/12534eb3-8109-4d84-83ad-576c0d5e1d06/resourcegroups/clients_e2e_test/providers/microsoft.insights/components/kusto-e2e-app-insights
4644
APPLICATION_INSIGHTS_TEST_DATABASE: kusto-e2e-app-insights
47-
run: uv run pytest --junit-xml pytest.xml
48-
49-
# todo: re-enable on a different PR
50-
# - name: "Run Ruff Formatter"
51-
# id: ruff-formatter
52-
# uses: astral-sh/ruff-action@v3
53-
# with:
54-
# args: "format --diff"
55-
#
56-
# - name: "Run Ruff Linter"
57-
# run: ruff check --diff
45+
run: uvx poe test --ci
5846

47+
# todo: re-enable on a different PR
48+
# - name: "Run Ruff Formatter"
49+
# id: ruff-formatter
50+
# uses: astral-sh/ruff-action@v3
51+
# with:
52+
# args: "format --diff"
53+
#
54+
# - name: "Run Ruff Linter"
55+
# run: ruff check --diff
56+
5957
- name: Upload Unit Test Results
6058
if: always()
6159
uses: actions/upload-artifact@v4

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,4 +308,6 @@ build/
308308
.mypy*
309309

310310

311-
*/.tox/
311+
*/.tox/
312+
313+
.env

CONTRIBUTING.md

Lines changed: 76 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,60 @@ If you would like to become an active contributor to this project please
44
follow the instructions provided in [Microsoft Azure Projects Contribution Guidelines](https://azure.github.io/azure-sdk/python_documentation.html).
55

66
## Prerequisites
7+
8+
### Cluster
79
In order to run E2E tests, you need a Kusto database you have admin rights on.
810
A Kusto free cluster is the easiest way to acquire one.
911
You can cerate a free Kusto cluster here: https://dataexplorer.azure.com/home
1012

1113
Make sure you set streaming ingestion to enabled in the cluster's configuration:
1214
https://learn.microsoft.com/en-us/azure/data-explorer/ingest-data-streaming?tabs=azure-portal%2Ccsharp
1315

14-
You should set then following environment vars where you run E2Es (in IDE run config, shell window, computer, etc).
16+
17+
### Tools
18+
19+
The project uses [uv](https://docs.astral.sh/uv/) as the project manager.
20+
You will need to install it in order to develop on this project.
21+
22+
See [Installing uv](https://docs.astral.sh/uv/getting-started/installation/).
23+
24+
Additionally, the project uses [poethepoet](https://poethepoet.natn.io/index.html) as the task runner.
25+
26+
You can install it with uv:
27+
28+
```bash
29+
uv tool install poethepoet
30+
31+
poe <command>
32+
```
33+
34+
Or you can use `uvx` to use it directly without installing:
35+
36+
```bash
37+
uvx poe <command>
38+
```
39+
40+
41+
### Environment Variables
42+
43+
Some tests require you to set environment variables to run.
44+
45+
The project supports a .env file, which you can create in the root of the project.
46+
See [.env.example](./.env.example) for an example of a .env file.
47+
48+
#### E2E Tests Environment Variables
49+
1550
```shell
16-
ENGINE_CONNECTION_STRING=<Your cluster URI>
17-
DM_CONNECTION_STRING=<Your ingest cluster URI> # Optional - if not set, will infer from ENGINE_CONNECTION_STRING
51+
ENGINE_CONNECTION_STRING=<Your cluster URI> # Format: https://<cluster_name>.<region>.kusto.windows.net
52+
DM_CONNECTION_STRING=<Your ingest cluster URI> # Optional - if not set, will infer from ENGINE_CONNECTION_STRING. Format: https://ingest-<cluster_name>.<region>.kusto.windows.net
1853
TEST_DATABASE=<The name of the database>
1954
```
2055

21-
The E2E tests authenticate with DefaultAzureCredential, and will fall back to interactive login if needed.
56+
The E2E tests authenticate with [DefaultAzureCredential](https://learn.microsoft.com/en-us/python/api/azure-identity/azure.identity.defaultazurecredential?view=azure-python).
2257

58+
It is recommended to use the [azure cli](https://learn.microsoft.com/en-us/cli/azure/install-azure-cli?view=azure-cli-latest) command `az login` to authenticate with your Azure account to run the tests.
2359

24-
For more information on DefaultAzureCredential, see:
25-
https://learn.microsoft.com/en-us/python/api/azure-identity/azure.identity.defaultazurecredential?view=azure-python
60+
#### Token Provider Tests
2661

2762
To run the optional `token_provider` tests, you will need to set the booleans at the top of the file `test_token_providers.py` and the following environment variables in addition to the previous ones:
2863
```shell
@@ -43,41 +78,61 @@ USER_PASS=<Your user password>
4378
USER_AUTH_ID=<Your user auth ID> # optional
4479
```
4580

46-
## Requirements
4781

48-
In order to work on this project, we recommend using the dev requirements:
82+
## Development
83+
84+
As mentioned before, this project uses `uv` and `poe` to manage the development environment and tasks.
85+
86+
To see the tasks available, you can run:
87+
88+
```bash
89+
poe
90+
```
91+
92+
### Setup
93+
94+
Setup the project by syncing `uv`:
4995

5096
```bash
51-
pip install -r dev_requirements.txt
97+
poe sync
5298
```
5399

54-
These including testing related packages as well as styling ([black](https://black.readthedocs.io/en/stable/))
100+
This will install the dependencies, set up the virtual environment, and install the tools needed for development.
55101

56-
## Building and Testing
102+
### Testing
57103

58104
This project uses [pytest](https://docs.pytest.org/en/latest/).
59105

106+
To test the project, simply run:
107+
108+
```bash
109+
poe test
110+
```
60111

61-
Since the tests use the package as a third-party, the easiest way to set it up is installing it in edit mode:
112+
To test without E2E tests, you can run:
62113

63114
```bash
64-
pip install -e ./azure-kusto-data ./azure-kusto-ingest
115+
poe test --no-e2e
65116
```
66117

67-
After which, running tests is simple.
118+
### Style
68119

69-
Just run:
120+
This project uses [ruff](https://docs.astral.sh/ruff/) for linting and formatting.
121+
122+
Before commiting your changes, make sure the code is properly formatted, or the commit will be rejected.
70123

71124
```bash
72-
pytest ./azure-kusto-data ./azure-kusto-ingest
125+
poe format # formats the code directly
126+
poe check-format # returns a diff of what needs to be formatted
73127
```
74128

75-
## Style
76-
77-
We use black, and allow for line-length of 160, so please run:
129+
Also make sure to lint the code:
78130

79131
```bash
80-
black --line-length=160 ./azure-kusto-data ./azure-kusto-ingest
132+
poe lint
133+
134+
# You can auto-fix some issues with:
135+
poe lint --fix
81136
```
82137

83138
## PRs
@@ -90,7 +145,7 @@ We welcome contributions. In order to make the PR process efficient, please foll
90145
* **Please provide any related information needed to understand the change** - docs, guidelines, use-case, best practices and so on. Opinions are accepted, but have to be backed up.
91146
* **Checks should pass** - these including linting with black and running tests.
92147

93-
## Code of Conduct
148+
# Code of Conduct
94149
This project's code of conduct can be found in the
95150
[CODE_OF_CONDUCT.md file](https://github.com/Azure/azure-sdk-for-python/blob/master/CODE_OF_CONDUCT.md)
96151
(v1.4.0 of the http://contributor-covenant.org/ CoC).

pyproject.toml

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,13 @@ email = "[email protected]"
1717
[dependency-groups]
1818
dev = [
1919
"pytest>=8.4.1",
20+
"pytest-xdist[psutil]>=3.8.0",
21+
"pytest-asyncio>=1.1.0",
2022
"responses>=0.25.8",
2123
"aioresponses>=0.7.8",
22-
"pytest-asyncio>=1.1.0",
2324
"asgiref>=3.9.1",
24-
"setuptools>=80.9.0",
25-
"ipython>=8.12.3",
26-
"pyarrow>=21.0.0",
2725
"pandas>=2.3.1",
2826
"ruff>=0.12.8",
29-
"basedpyright>=1.31.1",
30-
"pytest-xdist[psutil]>=3.8.0",
3127
]
3228

3329
[tool.uv.workspace]
@@ -51,5 +47,28 @@ ignore = ["E731"] # E731 - dont assign lambdas.
5147

5248
[tool.pytest.ini_options]
5349
testpaths = ["azure-kusto-data/tests", "azure-kusto-ingest/tests"]
54-
addopts = ["-s", "--import-mode=importlib", "-n", "8"]
50+
addopts = ["-s", "--import-mode=importlib", '-n', 'auto']
5551
pythonpath = ["."]
52+
53+
[tool.poe]
54+
envfile = ".env"
55+
56+
[tool.poe.tasks]
57+
sync = "uv sync --all-packages --all-extras --dev --locked"
58+
build = "uv build --all-packages"
59+
format = "ruff format"
60+
check-format = "ruff format --diff"
61+
lint = "ruff check"
62+
lint-fix = "ruff check --fix"
63+
lint-fix-unsafe = "ruff check --fix --unsafe-fixes"
64+
show-version = "uv version"
65+
[tool.poe.tasks.test]
66+
sequence = ["sync", { cmd = 'pytest ${NO_E2E:+ --ignore=azure-kusto-ingest/tests/test_e2e_ingest.py --ignore=azure-kusto-data/tests/test_e2e_data.py } ${CI:+ -n8 --junit-xml pytest.xml}'}]
67+
68+
[tool.poe.tasks.test.args]
69+
NO_E2E = { help = "Skip E2E tests", type = "boolean", options = ["--no-e2e"] }
70+
CI = { help = "Run tests in CI mode", type = "boolean", options = ["--ci"] }
71+
72+
[tool.poe.tasks.bump-version]
73+
sequence = [{ cmd = "uv version --bump $bump" }, { cmd = "uv version --bump $bump --package azure-kusto-data" }, { cmd = "uv version --bump $bump --package azure-kusto-ingest" }, { cmd = "uv version --bump $bump --package quick-start" }]
74+
args = { bump = { help = "Bump version [possible values: major, minor, patch, stable, alpha, beta, rc, post, dev]", positional = true, default = "patch" } }

0 commit comments

Comments
 (0)