diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 72080f00..ceab3db1 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -11,7 +11,7 @@ If you are worried or don’t know where to start, check out our next section ex Please help us keep SurrealDB open and inclusive. Kindly read and follow our [Code of Conduct](/CODE_OF_CONDUCT.md). diff --git a/README.md b/README.md index f695e941..2f413eb1 100644 --- a/README.md +++ b/README.md @@ -129,7 +129,58 @@ with Surreal("ws://localhost:8000/rpc") as db: ## Next steps 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). + ## Contributing + Contributions to this library are welcome! If you encounter issues, have feature requests, or want to make improvements, feel free to open issues or submit pull requests. +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). + +## Getting the repo up and running + +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: + +```bash +# if the docker-compose binary is installed +docker-compose up -d + +# if you are running docker compose directly through docker +docker compose up -d +``` + +Now that the database is running, we can enter a terminal session with all the requirements installed and `PYTHONPATH` configured with the command below: + +```bash +bash scripts/term.sh +``` + +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: + +```bash +python -m unittest discover +``` + +The number of tests might increase but at the time of writing this you should get a printout like the one below: + +```bash +.........................................................................................................................................Error in live subscription: sent 1000 (OK); no close frame received +.......................................................................................... +---------------------------------------------------------------------- +Ran 227 tests in 6.313s + +OK +``` +Finally, we clean up the database with the command below: +```bash +# if the docker-compose binary is installed +docker-compose down + +# if you are running docker compose directly through docker +docker compose down +``` +To exit the terminal session merely execute the following command: +```bash +exit +``` + And there we have it, our tests are passing. diff --git a/scripts/term.sh b/scripts/term.sh new file mode 100644 index 00000000..bdc6066b --- /dev/null +++ b/scripts/term.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +# navigate to directory +SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )" +cd $SCRIPTPATH + +# Define the PYTHONPATH for the terminal session +cd ../src +export PYTHONPATH=$(pwd) +cd .. + +# Configure the virtual environment if needed +if [ -d "venv" ]; then + echo "existing python virtual environment exists." +else + echo "python virtual environment does not exist. Creating one" + python3 -m venv venv +fi + +# start the terminal session +source venv/bin/activate +pip install -r requirements.txt +echo "now running in virtual environment. Execute the 'exit' to exit the virtual env terminal" +bash --norc diff --git a/scripts/setup.sh b/src/surrealdb/connections/mixins/__init__.py similarity index 100% rename from scripts/setup.sh rename to src/surrealdb/connections/mixins/__init__.py