Skip to content

Commit

Permalink
Merge branch 'main' into 20250114-documentation-tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
remade authored Jan 24, 2025
2 parents e1bd32d + 3187bc9 commit 9e76f93
Show file tree
Hide file tree
Showing 11 changed files with 128 additions and 12 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,4 @@ clog/
manifest/
.mypy_cache/
.ruff_cache/
tests/db_snapshots/
11 changes: 10 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,16 @@ services:
- SURREAL_PASS=root
- SURREAL_LOG=trace
ports:
- 8000:8000
- 8300:8000

surrealdb_big_data:
image: surrealdb-big-data
# environment:
# - SURREAL_USER=root
# - SURREAL_PASS=root
# - SURREAL_LOG=trace
ports:
- 9000:8000

surrealdb_200:
image: surrealdb/surrealdb:v2.0.0
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ classifiers = [
]

[build-system]
requires = ["setuptools", "wheel", "setuptools-rust"]
requires = ["setuptools", "wheel"]

[tool.poetry.dependencies]
python = "^3.10"
Expand Down
15 changes: 15 additions & 0 deletions scripts/download_snapshots.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash

# navigate to directory
SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"
cd $SCRIPTPATH

cd ..
cd tests

if [ -d "./db_snapshots" ]; then
echo "DB snapshots are already present"
rm -rf ./db_snapshots
fi

dockpack pull -i maxwellflitton/surrealdb-data -d ./db_snapshots
21 changes: 17 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import pathlib

from setuptools import setup
from setuptools_rust import Binding, RustExtension


with open("README.md", "r") as fh:
Expand All @@ -21,15 +20,29 @@
long_description=long_description,
long_description_content_type="text/markdown",
version=version,
rust_extensions=[RustExtension("surrealdb.rust_surrealdb", binding=Binding.PyO3)],
packages=[
"surrealdb",
"surrealdb.execution_mixins",
"surrealdb.async_execution_mixins"
"surrealdb.data",
"surrealdb.data.types"
],
package_data={
"surrealdb": ["binaries/*"],
},
install_requires=[
"cbor2==5.6.5",
"certifi==2024.12.14",
"charset-normalizer==3.4.0",
"idna==3.10",
"pytz==2024.2",
"requests==2.32.3",
"semantic-version==2.10.0",
"tomli==2.2.1",
"types-pytz==2024.2.0.20241003",
"types-requests==2.32.0.20241016",
"typing_extensions==4.12.2",
"urllib3==2.2.3",
"websockets==14.1",
],
# rust extensions are not zip safe, just like C-extensions.
zip_safe=False,
include_package_data=True
Expand Down
8 changes: 4 additions & 4 deletions surrealdb/data/types/datetime.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import pytz # type: ignore

from dataclasses import dataclass
from datetime import datetime
from math import floor
from typing import Tuple

import pytz # type: ignore
from math import floor


@dataclass
class DateTimeCompact:
timestamp: int = 0 # nanoseconds

@staticmethod
def parse(seconds: int, nanoseconds: int):
def parse(seconds: int, nanoseconds: int) -> "DateTimeCompact":
return DateTimeCompact(nanoseconds + (seconds * pow(10, 9)))

def get_seconds_and_nano(self) -> Tuple[int, int]:
Expand Down
3 changes: 2 additions & 1 deletion surrealdb/data/types/duration.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from dataclasses import dataclass
from math import floor
from typing import Tuple

from math import floor


@dataclass
class Duration:
Expand Down
17 changes: 17 additions & 0 deletions tests/builds/big_data_dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM debian:bullseye-slim

RUN apt-get update && apt-get install -y libpq-dev
RUN apt-get install -y curl
RUN apt-get install libssl-dev -y
RUN apt-get install tree -y
RUN apt-get install -y --no-install-recommends unzip bash
RUN curl -sSL https://raw.githubusercontent.com/maxwellflitton/surrealdb-backup-cli/main/scripts/install.sh | bash

COPY ./db_snapshots/big_data_snapshot/package/ ./big_data_snapshot/
RUN ./surrealdb_backup unpack -d ./unpacked_data/ -t ./big_data_snapshot/
RUN rm ./unpacked_data/LOCK
RUN curl -sSf https://install.surrealdb.com | sh

EXPOSE 8000

CMD ["surreal", "start", "--bind", "0.0.0.0:8000", "--allow-all", "--user", "root", "--pass", "root", "rocksdb:./unpacked_data"]
41 changes: 41 additions & 0 deletions tests/integration/async/test_batch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
from typing import List
from unittest import TestCase, main

from surrealdb import SurrealDB, RecordID
from tests.integration.connection_params import TestConnectionParams
import asyncio
import websockets


class TestBatch(TestCase):

def setUp(self) -> None:
self.params = TestConnectionParams()
self.db = SurrealDB(self.params.url)
self.queries: List[str] = []

self.db.connect()
self.db.use(self.params.namespace, self.params.database)
self.db.sign_in("root", "root")

# self.query = """
# CREATE |product:1000000| CONTENT {
# name: rand::enum('Cruiser Hoodie', 'Surreal T-Shirt'),
# colours: [rand::string(10), rand::string(10),],
# price: rand::int(20, 60),
# time: {
# created_at: rand::time(1611847404, 1706455404),
# updated_at: rand::time(1651155804, 1716906204)
# }
# };
# """
# self.db.query(query=self.query)

def tearDown(self) -> None:
pass

def test_batch(self):
print("test_batch")

if __name__ == '__main__':
main()
17 changes: 17 additions & 0 deletions tests/scripts/build_big_data_server.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash

# navigate to directory
SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"
cd $SCRIPTPATH

cd ..

if [ -d "./db_snapshots/big_data_snapshot" ]; then
echo "removing the big data snapshot"
rm -rf ./db_snapshots/big_data_snapshot
fi

dockpack pull -i maxwellflitton/surrealdb-data -d ./db_snapshots/big_data_snapshot
rm ./db_snapshots/big_data_snapshot/package/LOCK

docker build -f ./builds/big_data_dockerfile -t surrealdb-big-data .
4 changes: 3 additions & 1 deletion tests/unit/cbor_types/test_datetime.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from unittest import TestCase
from unittest import TestCase, main

from surrealdb.data.types.datetime import DateTimeCompact
from surrealdb.data.cbor import encode, decode
Expand All @@ -21,3 +21,5 @@ def test_datetime(self):
self.assertEqual(decoded.get_date_time(), '2024-12-12T09:00:58.083988Z')


if __name__ == '__main__':
main()

0 comments on commit 9e76f93

Please sign in to comment.