OpenGeodeWeb-Microservice 1.0.7rc1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Geode-solutions
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,56 @@
1
+ Metadata-Version: 2.4
2
+ Name: OpenGeodeWeb-Microservice
3
+ Version: 1.0.7rc1
4
+ Summary: Database model and ORM layer for OpenGeodeWeb ecosystem
5
+ Author-email: Geode-solutions <team-web@geode-solutions.com>
6
+ Project-URL: Homepage, https://github.com/Geode-solutions/OpenGeodeWeb-Microservice
7
+ Project-URL: Bug Tracker, https://github.com/Geode-solutions/OpenGeodeWeb-Microservice/issues
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Operating System :: OS Independent
11
+ Requires-Python: <3.13,>=3.9
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+ Requires-Dist: dataclasses-json>=0
15
+ Requires-Dist: fastjsonschema==2.21.1
16
+ Requires-Dist: greenlet>=3
17
+ Requires-Dist: marshmallow>=3
18
+ Requires-Dist: mypy-extensions>=1
19
+ Requires-Dist: packaging==25.0
20
+ Requires-Dist: sqlalchemy>=2
21
+ Requires-Dist: typing-extensions>=4
22
+ Requires-Dist: typing-inspect>=0
23
+ Dynamic: license-file
24
+
25
+ <h1 align="center">OpenGeodeWeb-Microservice<sup><i>by Geode-solutions</i></sup></h1>
26
+ <h3 align="center">OpenSource Python framework based on OpenGeode</h3>
27
+
28
+ <p align="center">
29
+ <img src="https://github.com/Geode-solutions/OpenGeodeWeb-Back/workflows/CI/badge.svg" alt="Build Status">
30
+ <img src="https://github.com/Geode-solutions/OpenGeodeWeb-Back/workflows/CD/badge.svg" alt="Deploy Status">
31
+ <img src="https://codecov.io/gh/Geode-solutions/OpenGeodeWeb-Back/branch/master/graph/badge.svg" alt="Coverage Status">
32
+ <img src="https://img.shields.io/github/release/Geode-solutions/OpenGeodeWeb-Back.svg" alt="Version">
33
+ <img src="https://img.shields.io/pypi/v/opengeode-core" alt="PyPI" >
34
+ </p>
35
+
36
+ <p align="center">
37
+ <img src="https://img.shields.io/badge/Python-3-blue.svg" alt="Language">
38
+ <img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="License">
39
+ <img src="https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg" alt="Semantic-release">
40
+ </p>
41
+
42
+ ---
43
+
44
+ ## Introduction
45
+
46
+ Database model and ORM layer for the OpenGeodeWeb ecosystem.
47
+
48
+ ## Changelog
49
+
50
+ Detailed changes for each release are documented in the [release notes](https://github.com/Geode-solutions/OpenGeodeWeb-Microservice/releases).
51
+
52
+ ## License
53
+
54
+ [MIT](https://opensource.org/licenses/MIT)
55
+
56
+ Copyright (c) 2019 - 2025, Geode-solutions
@@ -0,0 +1,32 @@
1
+ <h1 align="center">OpenGeodeWeb-Microservice<sup><i>by Geode-solutions</i></sup></h1>
2
+ <h3 align="center">OpenSource Python framework based on OpenGeode</h3>
3
+
4
+ <p align="center">
5
+ <img src="https://github.com/Geode-solutions/OpenGeodeWeb-Back/workflows/CI/badge.svg" alt="Build Status">
6
+ <img src="https://github.com/Geode-solutions/OpenGeodeWeb-Back/workflows/CD/badge.svg" alt="Deploy Status">
7
+ <img src="https://codecov.io/gh/Geode-solutions/OpenGeodeWeb-Back/branch/master/graph/badge.svg" alt="Coverage Status">
8
+ <img src="https://img.shields.io/github/release/Geode-solutions/OpenGeodeWeb-Back.svg" alt="Version">
9
+ <img src="https://img.shields.io/pypi/v/opengeode-core" alt="PyPI" >
10
+ </p>
11
+
12
+ <p align="center">
13
+ <img src="https://img.shields.io/badge/Python-3-blue.svg" alt="Language">
14
+ <img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="License">
15
+ <img src="https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg" alt="Semantic-release">
16
+ </p>
17
+
18
+ ---
19
+
20
+ ## Introduction
21
+
22
+ Database model and ORM layer for the OpenGeodeWeb ecosystem.
23
+
24
+ ## Changelog
25
+
26
+ Detailed changes for each release are documented in the [release notes](https://github.com/Geode-solutions/OpenGeodeWeb-Microservice/releases).
27
+
28
+ ## License
29
+
30
+ [MIT](https://opensource.org/licenses/MIT)
31
+
32
+ Copyright (c) 2019 - 2025, Geode-solutions
@@ -0,0 +1,30 @@
1
+ [build-system]
2
+ requires = ["setuptools"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "OpenGeodeWeb-Microservice"
7
+ version = "1.0.7-rc.1"
8
+ dynamic = ["dependencies"]
9
+ authors = [{ name = "Geode-solutions", email = "team-web@geode-solutions.com" }]
10
+ description = "Database model and ORM layer for OpenGeodeWeb ecosystem"
11
+ readme = "README.md"
12
+ requires-python = ">=3.9, <3.13"
13
+ classifiers = [
14
+ "Programming Language :: Python :: 3",
15
+ "License :: OSI Approved :: MIT License",
16
+ "Operating System :: OS Independent",
17
+ ]
18
+
19
+ [project.urls]
20
+ "Homepage" = "https://github.com/Geode-solutions/OpenGeodeWeb-Microservice"
21
+ "Bug Tracker" = "https://github.com/Geode-solutions/OpenGeodeWeb-Microservice/issues"
22
+
23
+ [tool.setuptools.dynamic]
24
+ dependencies = { file = ["requirements.txt"] }
25
+
26
+ [tool.setuptools.packages.find]
27
+ where = ["src"]
28
+
29
+ [tool.setuptools.package-data]
30
+ opengeodeweb_microservice = ["py.typed"]
@@ -0,0 +1,27 @@
1
+ #
2
+ # This file is autogenerated by pip-compile with Python 3.12
3
+ # by the following command:
4
+ #
5
+ # pip-compile --output-file=./requirements.txt ./requirements.in
6
+ #
7
+ dataclasses-json>=0
8
+ # via -r requirements.in
9
+ fastjsonschema==2.21.1
10
+ # via -r requirements.in
11
+ greenlet>=3
12
+ # via sqlalchemy
13
+ marshmallow>=3
14
+ # via dataclasses-json
15
+ mypy-extensions>=1
16
+ # via typing-inspect
17
+ packaging==25.0
18
+ # via marshmallow
19
+ sqlalchemy>=2
20
+ # via -r requirements.in
21
+ typing-extensions>=4
22
+ # via
23
+ # sqlalchemy
24
+ # typing-inspect
25
+ typing-inspect>=0
26
+ # via dataclasses-json
27
+
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,56 @@
1
+ Metadata-Version: 2.4
2
+ Name: OpenGeodeWeb-Microservice
3
+ Version: 1.0.7rc1
4
+ Summary: Database model and ORM layer for OpenGeodeWeb ecosystem
5
+ Author-email: Geode-solutions <team-web@geode-solutions.com>
6
+ Project-URL: Homepage, https://github.com/Geode-solutions/OpenGeodeWeb-Microservice
7
+ Project-URL: Bug Tracker, https://github.com/Geode-solutions/OpenGeodeWeb-Microservice/issues
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Operating System :: OS Independent
11
+ Requires-Python: <3.13,>=3.9
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+ Requires-Dist: dataclasses-json>=0
15
+ Requires-Dist: fastjsonschema==2.21.1
16
+ Requires-Dist: greenlet>=3
17
+ Requires-Dist: marshmallow>=3
18
+ Requires-Dist: mypy-extensions>=1
19
+ Requires-Dist: packaging==25.0
20
+ Requires-Dist: sqlalchemy>=2
21
+ Requires-Dist: typing-extensions>=4
22
+ Requires-Dist: typing-inspect>=0
23
+ Dynamic: license-file
24
+
25
+ <h1 align="center">OpenGeodeWeb-Microservice<sup><i>by Geode-solutions</i></sup></h1>
26
+ <h3 align="center">OpenSource Python framework based on OpenGeode</h3>
27
+
28
+ <p align="center">
29
+ <img src="https://github.com/Geode-solutions/OpenGeodeWeb-Back/workflows/CI/badge.svg" alt="Build Status">
30
+ <img src="https://github.com/Geode-solutions/OpenGeodeWeb-Back/workflows/CD/badge.svg" alt="Deploy Status">
31
+ <img src="https://codecov.io/gh/Geode-solutions/OpenGeodeWeb-Back/branch/master/graph/badge.svg" alt="Coverage Status">
32
+ <img src="https://img.shields.io/github/release/Geode-solutions/OpenGeodeWeb-Back.svg" alt="Version">
33
+ <img src="https://img.shields.io/pypi/v/opengeode-core" alt="PyPI" >
34
+ </p>
35
+
36
+ <p align="center">
37
+ <img src="https://img.shields.io/badge/Python-3-blue.svg" alt="Language">
38
+ <img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="License">
39
+ <img src="https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg" alt="Semantic-release">
40
+ </p>
41
+
42
+ ---
43
+
44
+ ## Introduction
45
+
46
+ Database model and ORM layer for the OpenGeodeWeb ecosystem.
47
+
48
+ ## Changelog
49
+
50
+ Detailed changes for each release are documented in the [release notes](https://github.com/Geode-solutions/OpenGeodeWeb-Microservice/releases).
51
+
52
+ ## License
53
+
54
+ [MIT](https://opensource.org/licenses/MIT)
55
+
56
+ Copyright (c) 2019 - 2025, Geode-solutions
@@ -0,0 +1,17 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ requirements.txt
5
+ src/OpenGeodeWeb_Microservice.egg-info/PKG-INFO
6
+ src/OpenGeodeWeb_Microservice.egg-info/SOURCES.txt
7
+ src/OpenGeodeWeb_Microservice.egg-info/dependency_links.txt
8
+ src/OpenGeodeWeb_Microservice.egg-info/requires.txt
9
+ src/OpenGeodeWeb_Microservice.egg-info/top_level.txt
10
+ src/opengeodeweb_microservice/__init__.py
11
+ src/opengeodeweb_microservice/py.typed
12
+ src/opengeodeweb_microservice/schemas.py
13
+ src/opengeodeweb_microservice/database/__init__.py
14
+ src/opengeodeweb_microservice/database/base.py
15
+ src/opengeodeweb_microservice/database/connection.py
16
+ src/opengeodeweb_microservice/database/data.py
17
+ tests/test_database.py
@@ -0,0 +1,9 @@
1
+ dataclasses-json>=0
2
+ fastjsonschema==2.21.1
3
+ greenlet>=3
4
+ marshmallow>=3
5
+ mypy-extensions>=1
6
+ packaging==25.0
7
+ sqlalchemy>=2
8
+ typing-extensions>=4
9
+ typing-inspect>=0
@@ -0,0 +1,5 @@
1
+ from sqlalchemy.orm import DeclarativeBase
2
+
3
+
4
+ class Base(DeclarativeBase):
5
+ pass
@@ -0,0 +1,37 @@
1
+ """Database connection management"""
2
+
3
+ from sqlalchemy import create_engine
4
+ from sqlalchemy.orm import sessionmaker, scoped_session, Session
5
+ from .base import Base
6
+
7
+ DATABASE_FILENAME = "project.db"
8
+
9
+ engine = None
10
+ session_factory = None
11
+ scoped_session_registry = None
12
+
13
+
14
+ def init_database(db_path: str = DATABASE_FILENAME, create_tables: bool = True) -> None:
15
+ global engine, session_factory, scoped_session_registry
16
+
17
+ if engine is None:
18
+ engine = create_engine(
19
+ f"sqlite:///{db_path}",
20
+ connect_args={"check_same_thread": False},
21
+ )
22
+ print(f"Database engine created for {db_path}", flush=True)
23
+ session_factory = sessionmaker(bind=engine)
24
+ scoped_session_registry = scoped_session(session_factory)
25
+ if create_tables:
26
+ Base.metadata.create_all(engine)
27
+ print(f"Database tables created for {db_path}", flush=True)
28
+ else:
29
+ print(f"Database connected (tables not created) for {db_path}", flush=True)
30
+ else:
31
+ print(f"Database engine already exists for {db_path}, reusing", flush=True)
32
+
33
+
34
+ def get_session() -> Session:
35
+ if scoped_session_registry is None:
36
+ raise RuntimeError()
37
+ return scoped_session_registry()
@@ -0,0 +1,47 @@
1
+ from sqlalchemy import String, JSON, select
2
+ from sqlalchemy.orm import Mapped, mapped_column
3
+ from .connection import get_session
4
+ from .base import Base
5
+ import uuid
6
+
7
+
8
+ class Data(Base):
9
+ __tablename__ = "datas"
10
+
11
+ id: Mapped[str] = mapped_column(
12
+ String, primary_key=True, default=lambda: str(uuid.uuid4()).replace("-", "")
13
+ )
14
+ geode_object: Mapped[str] = mapped_column(String, nullable=False)
15
+ viewer_object: Mapped[str] = mapped_column(String, nullable=False)
16
+
17
+ native_file_name: Mapped[str | None] = mapped_column(String, nullable=True)
18
+ viewable_file_name: Mapped[str | None] = mapped_column(String, nullable=True)
19
+
20
+ light_viewable: Mapped[str | None] = mapped_column(String, nullable=True)
21
+ input_file: Mapped[str | None] = mapped_column(String, nullable=True)
22
+ additional_files: Mapped[list[str] | None] = mapped_column(JSON, nullable=True)
23
+
24
+ @staticmethod
25
+ def create(
26
+ geode_object: str,
27
+ viewer_object: str,
28
+ input_file: str | None = None,
29
+ additional_files: list[str] | None = None,
30
+ ) -> "Data":
31
+ data_entry = Data(
32
+ geode_object=geode_object,
33
+ viewer_object=viewer_object,
34
+ input_file=input_file,
35
+ additional_files=additional_files,
36
+ )
37
+
38
+ session = get_session()
39
+ session.add(data_entry)
40
+ session.flush()
41
+ return data_entry
42
+
43
+ @staticmethod
44
+ def get(data_id: str) -> "Data | None":
45
+ session = get_session()
46
+ data_query = select(Data).where(Data.id == data_id)
47
+ return session.scalars(data_query).first()
@@ -0,0 +1,15 @@
1
+ import os
2
+ import glob
3
+ import json
4
+
5
+ type SchemaDict = dict[str, str]
6
+
7
+
8
+ def get_schemas_dict(path: str) -> dict[str, SchemaDict]:
9
+ schemas_dict: dict[str, SchemaDict] = {}
10
+ for json_file in glob.glob(os.path.join(path, "*.json")):
11
+ filename = os.path.basename(json_file)
12
+ with open(os.path.join(path, json_file), "r") as file:
13
+ file_content = json.load(file)
14
+ schemas_dict[os.path.splitext(filename)[0]] = file_content
15
+ return schemas_dict
@@ -0,0 +1,37 @@
1
+ from opengeodeweb_microservice.database.data import Data
2
+
3
+
4
+ def test_data_crud_operations(clean_database):
5
+ data = Data.create(
6
+ geode_object="test_object",
7
+ viewer_object="test_viewer",
8
+ input_file="test.txt",
9
+ additional_files=[],
10
+ )
11
+ print("id", data.id, flush=True)
12
+ assert data.id is not None
13
+ assert isinstance(data.id, str)
14
+
15
+ retrieved = Data.get(data.id)
16
+ assert retrieved is not None
17
+ assert isinstance(retrieved, Data)
18
+ assert retrieved.geode_object == "test_object"
19
+ assert retrieved.input_file == "test.txt"
20
+ assert retrieved.id == data.id
21
+ non_existent = Data.get("fake_id")
22
+ assert non_existent is None
23
+
24
+
25
+ def test_data_with_additional_files(clean_database):
26
+ files = ["file1.txt", "file2.txt"]
27
+ data = Data.create(
28
+ geode_object="test_files", viewer_object="test_viewer", additional_files=files
29
+ )
30
+ assert data.id is not None
31
+ assert isinstance(data.id, str)
32
+
33
+ retrieved = Data.get(data.id)
34
+ assert retrieved is not None
35
+ assert isinstance(retrieved, Data)
36
+ assert retrieved.additional_files == files
37
+ assert retrieved.geode_object == "test_files"