Skip to content

Commit 9963945

Browse files
authored
Astrapy-repl command (#385)
* astrapy-repl * banner in banner * handle log levels in the repl * add astrapy-repl screenshot * promote repl to general tool * tiny fix to an async test assertion
1 parent 7e9291d commit 9963945

8 files changed

Lines changed: 761 additions & 34 deletions

File tree

CHANGES

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
main
22
====
3+
Introduced `astrapy-repl` command for a ready-to-use interactive REPL
34
Event Observer API, to listen to events:
45
- this complements the standard logging mechanism;
56
- events are: warnings, payloads/responses, ...

DEVELOPING.md

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## Development and maintenance
1+
# Development and maintenance
22

33
First install `uv` (e.g. `pipx install uv`), then set up a dev environment with `make venv`, or equivalently:
44

@@ -18,9 +18,27 @@ With `make format-fix` the style and imports are autofixed (by `ruff`)
1818
Features must be thoroughly covered in tests (have a look at `tests/*` to infer
1919
naming convention and module structure).
2020

21-
### Running tests
21+
## astrapy-repl
2222

23-
#### Typical testing
23+
Astrapy comes with a REPL, a customized Python interactive shell, which pre-loads
24+
all relevant imports and comes with `client` and `database` objects instantiated and
25+
ready-to-use.
26+
27+
Just ensure you have defined the environment variable as you would need for testing (see below),
28+
or set them as command-line parameters. Start the shell with:
29+
30+
```
31+
astrapy-repl
32+
```
33+
34+
Try `-h` for more guidance on passing options. In a local development environment, you will
35+
have to launch it as `uv run astrapy-repl`.
36+
37+
![AstraPy, REPL screenshot](https://raw.githubusercontent.com/datastax/astrapy/main/pictures/astrapy_repl.png)
38+
39+
## Running tests
40+
41+
### Typical testing
2442

2543
In most cases you want to run the "base" test suite (the one in the CI/CD automation) against either Astra DB or a local Data API + HCD.
2644

@@ -30,7 +48,7 @@ Steps:
3048
- Export variables as in the `tests/env_templates/env.vectorize-minimal.template` example.
3149
- Run: `uv venv --python ">=3.8<3.13" && uv run pytest tests/base`
3250

33-
#### All available tests/targets
51+
### All available tests/targets
3452

3553
Tests are grouped in:
3654
- "base", covering general-purpose astrapy functionality. Divided in unit/integration;
@@ -60,18 +78,18 @@ and comment the environment flag that suppresses them (see the base Astra env te
6078
For non-Astra, the reranking-related tests run only if one sets
6179
`HEADER_RERANKING_API_KEY_NVIDIA="AstraCS:<dev token...>` (as shown in the Local/DockerCompose base env templates).
6280

63-
#### Docker vs. Podman
81+
### Docker vs. Podman
6482

6583
In case you use a different Docker-compatible container runtime (e.g. `podman`) and are running against the
6684
"DockerCompose" target make sure to export the environment variable such as `DOCKER_COMMAND_NAME="podman"`
6785
to maek the test startup logic work properly.
6886

69-
#### Keyspaces
87+
### Keyspaces
7088

7189
You shoud never need to worry about keyspaces. Tests use two keyspaces, which are created if not found, with default names.
7290
The env templates show how to override those names, if you want to.
7391

74-
#### Multiple Python versions
92+
### Multiple Python versions
7593

7694
If may be useful to run e.g. unit tests with multiple Python versions. You can have `uv`
7795
create more than one venv and specify the version, e.g. for each one:
@@ -89,7 +107,7 @@ assuming you activated a certain virtual env, you can run e.g.: `make format VEN
89107

90108
**Warning: Python 3.13+ currently not supported to run integration tests! (but the package itself is all right).**
91109

92-
#### Adding/changing dependencies
110+
### Adding/changing dependencies
93111

94112
After editing the `pyproject.toml`, make sure you run
95113

@@ -100,7 +118,7 @@ uv sync --dev
100118

101119
and then commit the new `uv.lock` to the repo as well.
102120

103-
#### Sample testing commands
121+
### Sample testing commands
104122

105123
Base:
106124

@@ -141,18 +159,18 @@ uv run pytest [...] -o log_cli=0
141159
uv run pytest [...] -o log_cli=1 --log-cli-level=10
142160
```
143161

144-
### Special tests
162+
## Special tests
145163

146164
The following are special provision to manage features under evolution or not
147165
entirely deployed to all environments. Typically they require manually passing
148166
certain environment variables, otherwise the associated tests are excluded from CI.
149167

150-
#### Cutting-edge features on `main`
168+
### Cutting-edge features on `main`
151169

152170
Prepend tests with a `ASTRAPY_TEST_LATEST_MAIN=y` for features found on `main` that are not released anywhere.
153171
_(Tip: run a code search first to see what is currently marked as such. Chances are nothing is.)_
154172

155-
### Publish-and-release
173+
## Publish-and-release
156174

157175
Releasing a new version happens through the Github `release` workflow, which includes all necessary testing
158176
plus a publish step to the test-PyPI.

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ Next steps:
9292
- [Data API reference](https://docs.datastax.com/en/astra-db-serverless/api-reference/overview.html)
9393
- [AstraPy reference](https://docs.datastax.com/en/astra-api-docs/_attachments/python-client/astrapy/index.html)
9494
- Package on [PyPI](https://pypi.org/project/astrapy/)
95+
- For interactive sessions, check the `astrapy-repl` command [here](DEVELOPING.md#astrapy-repl)
9596

9697
### Server-side embeddings
9798

0 commit comments

Comments
 (0)