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.
Files changed (77) hide show
  1. docker/Dockerfile +30 -0
  2. docker/docker-compose.yaml +58 -0
  3. docker/docker-compose_test.yaml +24 -0
  4. docker/start-docker-test.sh +6 -0
  5. docs/requirements.txt +10 -0
  6. docs/source/Changelog.md +2 -0
  7. docs/source/License.rst +7 -0
  8. docs/source/Methode.md +161 -0
  9. docs/source/_static/custom.css +8 -0
  10. docs/source/_static/favicon.ico +0 -0
  11. docs/source/_static/logo.png +0 -0
  12. docs/source/api/api.rst +15 -0
  13. docs/source/api/cli.rst +8 -0
  14. docs/source/api/weatherDB.broker.rst +10 -0
  15. docs/source/api/weatherDB.config.rst +7 -0
  16. docs/source/api/weatherDB.db.rst +23 -0
  17. docs/source/api/weatherDB.rst +22 -0
  18. docs/source/api/weatherDB.station.rst +56 -0
  19. docs/source/api/weatherDB.stations.rst +46 -0
  20. docs/source/api/weatherDB.utils.rst +22 -0
  21. docs/source/conf.py +137 -0
  22. docs/source/index.rst +33 -0
  23. docs/source/setup/Configuration.md +127 -0
  24. docs/source/setup/Hosting.md +9 -0
  25. docs/source/setup/Install.md +49 -0
  26. docs/source/setup/Quickstart.md +183 -0
  27. docs/source/setup/setup.rst +12 -0
  28. weatherdb/__init__.py +24 -0
  29. weatherdb/_version.py +1 -0
  30. weatherdb/alembic/README.md +8 -0
  31. weatherdb/alembic/alembic.ini +80 -0
  32. weatherdb/alembic/config.py +9 -0
  33. weatherdb/alembic/env.py +100 -0
  34. weatherdb/alembic/script.py.mako +26 -0
  35. weatherdb/alembic/versions/V1.0.0_initial_database_creation.py +898 -0
  36. weatherdb/alembic/versions/V1.0.2_more_charachters_for_settings+term_station_ma_raster.py +88 -0
  37. weatherdb/alembic/versions/V1.0.5_fix-ma-raster-values.py +152 -0
  38. weatherdb/alembic/versions/V1.0.6_update-views.py +22 -0
  39. weatherdb/broker.py +667 -0
  40. weatherdb/cli.py +214 -0
  41. weatherdb/config/ConfigParser.py +663 -0
  42. weatherdb/config/__init__.py +5 -0
  43. weatherdb/config/config_default.ini +162 -0
  44. weatherdb/db/__init__.py +3 -0
  45. weatherdb/db/connections.py +374 -0
  46. weatherdb/db/fixtures/RichterParameters.json +34 -0
  47. weatherdb/db/models.py +402 -0
  48. weatherdb/db/queries/get_quotient.py +155 -0
  49. weatherdb/db/views.py +165 -0
  50. weatherdb/station/GroupStation.py +710 -0
  51. weatherdb/station/StationBases.py +3108 -0
  52. weatherdb/station/StationET.py +111 -0
  53. weatherdb/station/StationP.py +807 -0
  54. weatherdb/station/StationPD.py +98 -0
  55. weatherdb/station/StationT.py +164 -0
  56. weatherdb/station/__init__.py +13 -0
  57. weatherdb/station/constants.py +21 -0
  58. weatherdb/stations/GroupStations.py +519 -0
  59. weatherdb/stations/StationsBase.py +1021 -0
  60. weatherdb/stations/StationsBaseTET.py +30 -0
  61. weatherdb/stations/StationsET.py +17 -0
  62. weatherdb/stations/StationsP.py +128 -0
  63. weatherdb/stations/StationsPD.py +24 -0
  64. weatherdb/stations/StationsT.py +21 -0
  65. weatherdb/stations/__init__.py +11 -0
  66. weatherdb/utils/TimestampPeriod.py +369 -0
  67. weatherdb/utils/__init__.py +3 -0
  68. weatherdb/utils/dwd.py +350 -0
  69. weatherdb/utils/geometry.py +69 -0
  70. weatherdb/utils/get_data.py +285 -0
  71. weatherdb/utils/logging.py +126 -0
  72. weatherdb-1.1.0.dist-info/LICENSE +674 -0
  73. weatherdb-1.1.0.dist-info/METADATA +765 -0
  74. weatherdb-1.1.0.dist-info/RECORD +77 -0
  75. weatherdb-1.1.0.dist-info/WHEEL +5 -0
  76. weatherdb-1.1.0.dist-info/entry_points.txt +2 -0
  77. weatherdb-1.1.0.dist-info/top_level.txt +3 -0
@@ -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"}