weatherdb 1.1.0__py3-none-any.whl
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.
- docker/Dockerfile +30 -0
- docker/docker-compose.yaml +58 -0
- docker/docker-compose_test.yaml +24 -0
- docker/start-docker-test.sh +6 -0
- docs/requirements.txt +10 -0
- docs/source/Changelog.md +2 -0
- docs/source/License.rst +7 -0
- docs/source/Methode.md +161 -0
- docs/source/_static/custom.css +8 -0
- docs/source/_static/favicon.ico +0 -0
- docs/source/_static/logo.png +0 -0
- docs/source/api/api.rst +15 -0
- docs/source/api/cli.rst +8 -0
- docs/source/api/weatherDB.broker.rst +10 -0
- docs/source/api/weatherDB.config.rst +7 -0
- docs/source/api/weatherDB.db.rst +23 -0
- docs/source/api/weatherDB.rst +22 -0
- docs/source/api/weatherDB.station.rst +56 -0
- docs/source/api/weatherDB.stations.rst +46 -0
- docs/source/api/weatherDB.utils.rst +22 -0
- docs/source/conf.py +137 -0
- docs/source/index.rst +33 -0
- docs/source/setup/Configuration.md +127 -0
- docs/source/setup/Hosting.md +9 -0
- docs/source/setup/Install.md +49 -0
- docs/source/setup/Quickstart.md +183 -0
- docs/source/setup/setup.rst +12 -0
- weatherdb/__init__.py +24 -0
- weatherdb/_version.py +1 -0
- weatherdb/alembic/README.md +8 -0
- weatherdb/alembic/alembic.ini +80 -0
- weatherdb/alembic/config.py +9 -0
- weatherdb/alembic/env.py +100 -0
- weatherdb/alembic/script.py.mako +26 -0
- weatherdb/alembic/versions/V1.0.0_initial_database_creation.py +898 -0
- weatherdb/alembic/versions/V1.0.2_more_charachters_for_settings+term_station_ma_raster.py +88 -0
- weatherdb/alembic/versions/V1.0.5_fix-ma-raster-values.py +152 -0
- weatherdb/alembic/versions/V1.0.6_update-views.py +22 -0
- weatherdb/broker.py +667 -0
- weatherdb/cli.py +214 -0
- weatherdb/config/ConfigParser.py +663 -0
- weatherdb/config/__init__.py +5 -0
- weatherdb/config/config_default.ini +162 -0
- weatherdb/db/__init__.py +3 -0
- weatherdb/db/connections.py +374 -0
- weatherdb/db/fixtures/RichterParameters.json +34 -0
- weatherdb/db/models.py +402 -0
- weatherdb/db/queries/get_quotient.py +155 -0
- weatherdb/db/views.py +165 -0
- weatherdb/station/GroupStation.py +710 -0
- weatherdb/station/StationBases.py +3108 -0
- weatherdb/station/StationET.py +111 -0
- weatherdb/station/StationP.py +807 -0
- weatherdb/station/StationPD.py +98 -0
- weatherdb/station/StationT.py +164 -0
- weatherdb/station/__init__.py +13 -0
- weatherdb/station/constants.py +21 -0
- weatherdb/stations/GroupStations.py +519 -0
- weatherdb/stations/StationsBase.py +1021 -0
- weatherdb/stations/StationsBaseTET.py +30 -0
- weatherdb/stations/StationsET.py +17 -0
- weatherdb/stations/StationsP.py +128 -0
- weatherdb/stations/StationsPD.py +24 -0
- weatherdb/stations/StationsT.py +21 -0
- weatherdb/stations/__init__.py +11 -0
- weatherdb/utils/TimestampPeriod.py +369 -0
- weatherdb/utils/__init__.py +3 -0
- weatherdb/utils/dwd.py +350 -0
- weatherdb/utils/geometry.py +69 -0
- weatherdb/utils/get_data.py +285 -0
- weatherdb/utils/logging.py +126 -0
- weatherdb-1.1.0.dist-info/LICENSE +674 -0
- weatherdb-1.1.0.dist-info/METADATA +765 -0
- weatherdb-1.1.0.dist-info/RECORD +77 -0
- weatherdb-1.1.0.dist-info/WHEEL +5 -0
- weatherdb-1.1.0.dist-info/entry_points.txt +2 -0
- weatherdb-1.1.0.dist-info/top_level.txt +3 -0
weatherdb/alembic/env.py
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
from alembic import context
|
2
|
+
import re
|
3
|
+
from setuptools_scm import get_version
|
4
|
+
from packaging.version import parse as vparse
|
5
|
+
|
6
|
+
import weatherdb as wdb
|
7
|
+
from weatherdb.db.models import ModelBase
|
8
|
+
from weatherdb.db.connections import db_engine
|
9
|
+
|
10
|
+
# this is the Alembic Config object, which provides
|
11
|
+
# access to the values within the .ini file in use.
|
12
|
+
config = context.config
|
13
|
+
|
14
|
+
# add your model's MetaData object here
|
15
|
+
# for 'autogenerate' support
|
16
|
+
# in console do: weatherdb>alembic -c alembic\alembic.ini revision --autogenerate -m "comment" --rev-id "V1.0.0"
|
17
|
+
target_metadata = ModelBase.metadata
|
18
|
+
|
19
|
+
# check for alembic database copnnection in the WeatherDB config
|
20
|
+
# ##############################################################
|
21
|
+
engine = config.attributes.get("engine", None)
|
22
|
+
if engine is None and \
|
23
|
+
wdb.config.has_option('alembic', 'connection') and \
|
24
|
+
wdb.config.has_section(f'database:{wdb.config.get("alembic", "connection")}'):
|
25
|
+
print("Setting the database connection to the users configuration of 'alembic.connection'.")
|
26
|
+
wdb.config.set(
|
27
|
+
'database',
|
28
|
+
'connection',
|
29
|
+
wdb.config.get("alembic", "connection"))
|
30
|
+
engine = db_engine.engine
|
31
|
+
|
32
|
+
# get other values from config
|
33
|
+
# ############################
|
34
|
+
exclude_tables = re.sub(
|
35
|
+
r"\s+",
|
36
|
+
'',
|
37
|
+
config.get_main_option('exclude_tables', '')
|
38
|
+
).split(',')
|
39
|
+
valid_schemas = ModelBase.metadata._schemas
|
40
|
+
valid_tables = {
|
41
|
+
schema: [table.name
|
42
|
+
for table in ModelBase.metadata.tables.values()
|
43
|
+
if table.schema == schema]
|
44
|
+
for schema in ModelBase.metadata._schemas}
|
45
|
+
|
46
|
+
def include_name(name, type_, parent_names, *args,**kwargs):
|
47
|
+
if type_ == "schema":
|
48
|
+
return (name in valid_schemas) or (name is None)
|
49
|
+
else:
|
50
|
+
schema = parent_names["schema_name"] if parent_names["schema_name"] is not None else "public"
|
51
|
+
if schema not in valid_schemas:
|
52
|
+
return False
|
53
|
+
|
54
|
+
if type_ == "table":
|
55
|
+
return name in valid_tables.get(schema, []) and name not in exclude_tables
|
56
|
+
|
57
|
+
table = parent_names["table_name"]
|
58
|
+
return table in valid_tables.get(schema, []) and table not in exclude_tables
|
59
|
+
|
60
|
+
|
61
|
+
# get revision id
|
62
|
+
# ###############
|
63
|
+
def process_revision_directives(context, revision, directives):
|
64
|
+
# extract Migration
|
65
|
+
migration_script = directives[0]
|
66
|
+
|
67
|
+
# get version from setuptools_scm or WeatherDB if not in git
|
68
|
+
try:
|
69
|
+
version = vparse(get_version(root="..", relative_to=wdb.__file__))
|
70
|
+
except LookupError:
|
71
|
+
version = vparse(wdb.__version__)
|
72
|
+
migration_script.rev_id = f"V{version.base_version}"
|
73
|
+
|
74
|
+
|
75
|
+
# migration functions
|
76
|
+
# ###################
|
77
|
+
def run_migrations_online() -> None:
|
78
|
+
"""Run migrations in 'online' mode.
|
79
|
+
|
80
|
+
In this scenario we need to create an Engine
|
81
|
+
and associate a connection with the context.
|
82
|
+
|
83
|
+
"""
|
84
|
+
with engine.connect() as connection:
|
85
|
+
context.configure(
|
86
|
+
connection=connection,
|
87
|
+
target_metadata=target_metadata,
|
88
|
+
include_schemas=True,
|
89
|
+
include_name=include_name,
|
90
|
+
process_revision_directives=process_revision_directives,
|
91
|
+
)
|
92
|
+
|
93
|
+
with context.begin_transaction():
|
94
|
+
context.run_migrations()
|
95
|
+
|
96
|
+
|
97
|
+
if context.is_offline_mode():
|
98
|
+
raise NotImplementedError("offline mode is not supported")
|
99
|
+
else:
|
100
|
+
run_migrations_online()
|
@@ -0,0 +1,26 @@
|
|
1
|
+
"""${message}
|
2
|
+
|
3
|
+
Revision ID: ${up_revision}
|
4
|
+
Revises: ${down_revision | comma,n}
|
5
|
+
Create Date: ${create_date}
|
6
|
+
|
7
|
+
"""
|
8
|
+
from typing import Sequence, Union
|
9
|
+
|
10
|
+
from alembic import op
|
11
|
+
import sqlalchemy as sa
|
12
|
+
${imports if imports else ""}
|
13
|
+
|
14
|
+
# revision identifiers, used by Alembic.
|
15
|
+
revision: str = ${repr(up_revision)}
|
16
|
+
down_revision: Union[str, None] = ${repr(down_revision)}
|
17
|
+
branch_labels: Union[str, Sequence[str], None] = ${repr(branch_labels)}
|
18
|
+
depends_on: Union[str, Sequence[str], None] = ${repr(depends_on)}
|
19
|
+
|
20
|
+
|
21
|
+
def upgrade() -> None:
|
22
|
+
${upgrades if upgrades else "pass"}
|
23
|
+
|
24
|
+
|
25
|
+
def downgrade() -> None:
|
26
|
+
${downgrades if downgrades else "pass"}
|