OpenGeodeWeb-Microservice 1.0.0__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,50 @@
1
+ Metadata-Version: 2.4
2
+ Name: OpenGeodeWeb-Microservice
3
+ Version: 1.0.0
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: SQLAlchemy==2.0.43
15
+ Requires-Dist: Flask-SQLAlchemy==3.1.1
16
+ Requires-Dist: fastjsonschema==2.21.1
17
+ Dynamic: license-file
18
+
19
+ <h1 align="center">OpenGeodeWeb-Back<sup><i>by Geode-solutions</i></sup></h1>
20
+ <h3 align="center">OpenSource Python framework based on OpenGeode</h3>
21
+
22
+ <p align="center">
23
+ <img src="https://github.com/Geode-solutions/OpenGeodeWeb-Back/workflows/CI/badge.svg" alt="Build Status">
24
+ <img src="https://github.com/Geode-solutions/OpenGeodeWeb-Back/workflows/CD/badge.svg" alt="Deploy Status">
25
+ <img src="https://codecov.io/gh/Geode-solutions/OpenGeodeWeb-Back/branch/master/graph/badge.svg" alt="Coverage Status">
26
+ <img src="https://img.shields.io/github/release/Geode-solutions/OpenGeodeWeb-Back.svg" alt="Version">
27
+ <img src="https://img.shields.io/pypi/v/opengeode-core" alt="PyPI" >
28
+ </p>
29
+
30
+ <p align="center">
31
+ <img src="https://img.shields.io/badge/Python-3-blue.svg" alt="Language">
32
+ <img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="License">
33
+ <img src="https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg" alt="Semantic-release">
34
+ </p>
35
+
36
+ ---
37
+
38
+ ## Introduction
39
+
40
+ Database model and ORM layer for the OpenGeodeWeb ecosystem.
41
+
42
+ ## Changelog
43
+
44
+ Detailed changes for each release are documented in the [release notes](https://github.com/Geode-solutions/OpenGeodeWeb-Microservice/releases).
45
+
46
+ ## License
47
+
48
+ [MIT](https://opensource.org/licenses/MIT)
49
+
50
+ Copyright (c) 2019 - 2025, Geode-solutions
@@ -0,0 +1,32 @@
1
+ <h1 align="center">OpenGeodeWeb-Back<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.0"
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,3 @@
1
+ SQLAlchemy==2.0.43
2
+ Flask-SQLAlchemy==3.1.1
3
+ fastjsonschema==2.21.1
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,50 @@
1
+ Metadata-Version: 2.4
2
+ Name: OpenGeodeWeb-Microservice
3
+ Version: 1.0.0
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: SQLAlchemy==2.0.43
15
+ Requires-Dist: Flask-SQLAlchemy==3.1.1
16
+ Requires-Dist: fastjsonschema==2.21.1
17
+ Dynamic: license-file
18
+
19
+ <h1 align="center">OpenGeodeWeb-Back<sup><i>by Geode-solutions</i></sup></h1>
20
+ <h3 align="center">OpenSource Python framework based on OpenGeode</h3>
21
+
22
+ <p align="center">
23
+ <img src="https://github.com/Geode-solutions/OpenGeodeWeb-Back/workflows/CI/badge.svg" alt="Build Status">
24
+ <img src="https://github.com/Geode-solutions/OpenGeodeWeb-Back/workflows/CD/badge.svg" alt="Deploy Status">
25
+ <img src="https://codecov.io/gh/Geode-solutions/OpenGeodeWeb-Back/branch/master/graph/badge.svg" alt="Coverage Status">
26
+ <img src="https://img.shields.io/github/release/Geode-solutions/OpenGeodeWeb-Back.svg" alt="Version">
27
+ <img src="https://img.shields.io/pypi/v/opengeode-core" alt="PyPI" >
28
+ </p>
29
+
30
+ <p align="center">
31
+ <img src="https://img.shields.io/badge/Python-3-blue.svg" alt="Language">
32
+ <img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="License">
33
+ <img src="https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg" alt="Semantic-release">
34
+ </p>
35
+
36
+ ---
37
+
38
+ ## Introduction
39
+
40
+ Database model and ORM layer for the OpenGeodeWeb ecosystem.
41
+
42
+ ## Changelog
43
+
44
+ Detailed changes for each release are documented in the [release notes](https://github.com/Geode-solutions/OpenGeodeWeb-Microservice/releases).
45
+
46
+ ## License
47
+
48
+ [MIT](https://opensource.org/licenses/MIT)
49
+
50
+ 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/database/__init__.py
13
+ src/opengeodeweb_microservice/database/base.py
14
+ src/opengeodeweb_microservice/database/connection.py
15
+ src/opengeodeweb_microservice/database/data.py
16
+ tests/test_connection.py
17
+ tests/test_database.py
@@ -0,0 +1,3 @@
1
+ SQLAlchemy==2.0.43
2
+ Flask-SQLAlchemy==3.1.1
3
+ fastjsonschema==2.21.1
@@ -0,0 +1,7 @@
1
+ from flask import Flask
2
+ from flask_sqlalchemy import SQLAlchemy
3
+ from sqlalchemy.orm import DeclarativeBase
4
+
5
+
6
+ class Base(DeclarativeBase):
7
+ pass
@@ -0,0 +1,29 @@
1
+ """Database connection management"""
2
+
3
+ from typing import Optional
4
+ from sqlalchemy.orm import scoped_session
5
+ from flask import Flask
6
+ from flask_sqlalchemy import SQLAlchemy
7
+ from flask_sqlalchemy.session import Session
8
+ from .base import Base
9
+
10
+ DATABASE_FILENAME = "project.db"
11
+ db: Optional[SQLAlchemy] = None
12
+
13
+
14
+ def init_database(app: Flask, db_filename: str = DATABASE_FILENAME) -> SQLAlchemy:
15
+ global db
16
+ if db is None:
17
+ db = SQLAlchemy(model_class=Base)
18
+ db.init_app(app)
19
+ with app.app_context():
20
+ db.create_all()
21
+ return db
22
+
23
+
24
+ def get_database() -> Optional[SQLAlchemy]:
25
+ return db
26
+
27
+
28
+ def get_session() -> Optional[scoped_session[Session]]:
29
+ return db.session if db else None
@@ -0,0 +1,52 @@
1
+ from sqlalchemy import String, JSON
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
+ native_file_name: Mapped[str] = mapped_column(String, nullable=False)
15
+ viewable_file_name: Mapped[str] = mapped_column(String, nullable=False)
16
+ geode_object: Mapped[str] = mapped_column(String, nullable=False)
17
+
18
+ light_viewable: Mapped[str | None] = mapped_column(String, nullable=True)
19
+ input_file: Mapped[str | None] = mapped_column(String, nullable=True)
20
+ additional_files: Mapped[list[str] | None] = mapped_column(JSON, nullable=True)
21
+
22
+ @staticmethod
23
+ def create(
24
+ geode_object: str,
25
+ input_file: str | None = None,
26
+ additional_files: list[str] | None = None,
27
+ ) -> "Data":
28
+ input_file = input_file if input_file is not None else ""
29
+ additional_files = additional_files if additional_files is not None else []
30
+
31
+ data_entry = Data(
32
+ geode_object=geode_object,
33
+ input_file=input_file,
34
+ additional_files=additional_files,
35
+ native_file_name="",
36
+ viewable_file_name="",
37
+ light_viewable=None,
38
+ )
39
+
40
+ session = get_session()
41
+ if session:
42
+ session.add(data_entry)
43
+ session.flush()
44
+ session.commit()
45
+ return data_entry
46
+
47
+ @staticmethod
48
+ def get(data_id: str) -> "Data | None":
49
+ session = get_session()
50
+ if session:
51
+ return session.get(Data, data_id)
52
+ return None
@@ -0,0 +1,9 @@
1
+ from src.opengeodeweb_microservice.database.connection import get_session, get_database
2
+ from src.opengeodeweb_microservice.database.data import Data
3
+
4
+
5
+ def test_database_connection_basic(app_context):
6
+ session = get_session()
7
+ assert session is not None
8
+ connection = get_database()
9
+ assert connection is not None
@@ -0,0 +1,23 @@
1
+ from src.opengeodeweb_microservice.database.connection import get_session
2
+ from src.opengeodeweb_microservice.database.data import Data
3
+
4
+
5
+ def test_data_crud_operations():
6
+ data = Data.create(geode_object="test_object", input_file="test.txt")
7
+ assert data.id is not None
8
+ session = get_session()
9
+ session.commit()
10
+ retrieved = Data.get(data.id)
11
+ assert retrieved is not None
12
+ assert retrieved.geode_object == "test_object"
13
+ non_existent = Data.get("fake_id")
14
+ assert non_existent is None
15
+
16
+
17
+ def test_data_with_additional_files():
18
+ files = ["file1.txt", "file2.txt"]
19
+ data = Data.create(geode_object="test_files", additional_files=files)
20
+ session = get_session()
21
+ session.commit()
22
+ retrieved = Data.get(data.id)
23
+ assert retrieved.additional_files == files