Skip to content

Commit dadef19

Browse files
authoredFeb 25, 2025
Contributing docs (#162)
1 parent 4aed495 commit dadef19

File tree

4 files changed

+76
-1
lines changed

4 files changed

+76
-1
lines changed
 

‎CONTRIBUTING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ If you are worried or don’t know where to start, check out our next section ex
1111
Please help us keep SurrealDB open and inclusive. Kindly read and follow our [Code of Conduct](/CODE_OF_CONDUCT.md).
1212

1313
<!--
14-
--------------------------------------------------
14+
---**----**-------------------------------------------
1515
ONLY RELEVANT FOR CLIENT SDK REPOSITORIES
1616
--------------------------------------------------
1717
-->

‎README.md

+51
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,58 @@ with Surreal("ws://localhost:8000/rpc") as db:
129129
## Next steps
130130

131131
Now that you have learned the basics of the SurrealDB SDK for Python, you can learn more about the SDK and its methods [in the methods section](https://surrealdb.com/docs/sdk/python/methods) and [data types section](https://surrealdb.com/docs/sdk/python/data-types).
132+
132133
## Contributing
134+
133135
Contributions to this library are welcome! If you encounter issues, have feature requests, or
134136
want to make improvements, feel free to open issues or submit pull requests.
135137

138+
If you want to contribute to the Github repo please read the general contributing guidelines on concepts such as how to create a pull requests [here](https://github.com/surrealdb/surrealdb.py/blob/main/CONTRIBUTING.md).
139+
140+
## Getting the repo up and running
141+
142+
To contribute, it's a good idea to get the repo up and running first. We can do this by running the tests. If the tests pass, your `PYTHONPATH` works and the client is making successful calls to the database. To do this we must run the database with the following command:
143+
144+
```bash
145+
# if the docker-compose binary is installed
146+
docker-compose up -d
147+
148+
# if you are running docker compose directly through docker
149+
docker compose up -d
150+
```
151+
152+
Now that the database is running, we can enter a terminal session with all the requirements installed and `PYTHONPATH` configured with the command below:
153+
154+
```bash
155+
bash scripts/term.sh
156+
```
157+
158+
You will now be running an interactive terminal through a python virtual environment with all the dependencies installed. We can now run the tests with the following command:
159+
160+
```bash
161+
python -m unittest discover
162+
```
163+
164+
The number of tests might increase but at the time of writing this you should get a printout like the one below:
165+
166+
```bash
167+
.........................................................................................................................................Error in live subscription: sent 1000 (OK); no close frame received
168+
..........................................................................................
169+
----------------------------------------------------------------------
170+
Ran 227 tests in 6.313s
171+
172+
OK
173+
```
174+
Finally, we clean up the database with the command below:
175+
```bash
176+
# if the docker-compose binary is installed
177+
docker-compose down
178+
179+
# if you are running docker compose directly through docker
180+
docker compose down
181+
```
182+
To exit the terminal session merely execute the following command:
183+
```bash
184+
exit
185+
```
186+
And there we have it, our tests are passing.

‎scripts/term.sh

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/env bash
2+
3+
# navigate to directory
4+
SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"
5+
cd $SCRIPTPATH
6+
7+
# Define the PYTHONPATH for the terminal session
8+
cd ../src
9+
export PYTHONPATH=$(pwd)
10+
cd ..
11+
12+
# Configure the virtual environment if needed
13+
if [ -d "venv" ]; then
14+
echo "existing python virtual environment exists."
15+
else
16+
echo "python virtual environment does not exist. Creating one"
17+
python3 -m venv venv
18+
fi
19+
20+
# start the terminal session
21+
source venv/bin/activate
22+
pip install -r requirements.txt
23+
echo "now running in virtual environment. Execute the 'exit' to exit the virtual env terminal"
24+
bash --norc
File renamed without changes.

0 commit comments

Comments
 (0)