pandahub 0.3.10__zip → 0.3.12__zip

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 (49) hide show
  1. {pandahub-0.3.10 → pandahub-0.3.12}/CHANGELOG.md +4 -0
  2. {pandahub-0.3.10 → pandahub-0.3.12}/PKG-INFO +1 -1
  3. {pandahub-0.3.10 → pandahub-0.3.12}/pandahub/lib/PandaHub.py +10 -14
  4. {pandahub-0.3.10 → pandahub-0.3.12}/pandahub/lib/database_toolbox.py +17 -0
  5. {pandahub-0.3.10 → pandahub-0.3.12}/pandahub.egg-info/PKG-INFO +1 -1
  6. {pandahub-0.3.10 → pandahub-0.3.12}/pyproject.toml +1 -1
  7. {pandahub-0.3.10 → pandahub-0.3.12}/CONTRIBUTING.rst +0 -0
  8. {pandahub-0.3.10 → pandahub-0.3.12}/LICENSE +0 -0
  9. {pandahub-0.3.10 → pandahub-0.3.12}/MANIFEST.in +0 -0
  10. {pandahub-0.3.10 → pandahub-0.3.12}/README.md +0 -0
  11. {pandahub-0.3.10 → pandahub-0.3.12}/pandahub/__init__.py +0 -0
  12. {pandahub-0.3.10 → pandahub-0.3.12}/pandahub/api/__init__.py +0 -0
  13. {pandahub-0.3.10 → pandahub-0.3.12}/pandahub/api/dependencies.py +0 -0
  14. {pandahub-0.3.10 → pandahub-0.3.12}/pandahub/api/internal/__init__.py +0 -0
  15. {pandahub-0.3.10 → pandahub-0.3.12}/pandahub/api/internal/db.py +0 -0
  16. {pandahub-0.3.10 → pandahub-0.3.12}/pandahub/api/internal/schemas.py +0 -0
  17. {pandahub-0.3.10 → pandahub-0.3.12}/pandahub/api/internal/settings.py +0 -0
  18. {pandahub-0.3.10 → pandahub-0.3.12}/pandahub/api/internal/toolbox.py +0 -0
  19. {pandahub-0.3.10 → pandahub-0.3.12}/pandahub/api/internal/users.py +0 -0
  20. {pandahub-0.3.10 → pandahub-0.3.12}/pandahub/api/main.py +0 -0
  21. {pandahub-0.3.10 → pandahub-0.3.12}/pandahub/api/routers/__init__.py +0 -0
  22. {pandahub-0.3.10 → pandahub-0.3.12}/pandahub/api/routers/auth.py +0 -0
  23. {pandahub-0.3.10 → pandahub-0.3.12}/pandahub/api/routers/net.py +0 -0
  24. {pandahub-0.3.10 → pandahub-0.3.12}/pandahub/api/routers/projects.py +0 -0
  25. {pandahub-0.3.10 → pandahub-0.3.12}/pandahub/api/routers/timeseries.py +0 -0
  26. {pandahub-0.3.10 → pandahub-0.3.12}/pandahub/api/routers/users.py +0 -0
  27. {pandahub-0.3.10 → pandahub-0.3.12}/pandahub/api/routers/variants.py +0 -0
  28. {pandahub-0.3.10 → pandahub-0.3.12}/pandahub/lib/__init__.py +0 -0
  29. {pandahub-0.3.10 → pandahub-0.3.12}/pandahub/lib/datatypes.py +0 -0
  30. {pandahub-0.3.10 → pandahub-0.3.12}/pandahub/lib/mongodb_indexes.py +0 -0
  31. {pandahub-0.3.10 → pandahub-0.3.12}/pandahub/lib/timeseries/__init__.py +0 -0
  32. {pandahub-0.3.10 → pandahub-0.3.12}/pandahub/lib/timeseries/data_sources/__init__.py +0 -0
  33. {pandahub-0.3.10 → pandahub-0.3.12}/pandahub/lib/timeseries/data_sources/mongo_data.py +0 -0
  34. {pandahub-0.3.10 → pandahub-0.3.12}/pandahub/lib/timeseries/output_writer_mongodb.py +0 -0
  35. {pandahub-0.3.10 → pandahub-0.3.12}/pandahub.egg-info/SOURCES.txt +0 -0
  36. {pandahub-0.3.10 → pandahub-0.3.12}/pandahub.egg-info/dependency_links.txt +0 -0
  37. {pandahub-0.3.10 → pandahub-0.3.12}/pandahub.egg-info/requires.txt +0 -0
  38. {pandahub-0.3.10 → pandahub-0.3.12}/pandahub.egg-info/top_level.txt +0 -0
  39. {pandahub-0.3.10 → pandahub-0.3.12}/requirements.txt +0 -0
  40. {pandahub-0.3.10 → pandahub-0.3.12}/setup.cfg +0 -0
  41. {pandahub-0.3.10 → pandahub-0.3.12}/setup.py +0 -0
  42. {pandahub-0.3.10 → pandahub-0.3.12}/test/__init__.py +0 -0
  43. {pandahub-0.3.10 → pandahub-0.3.12}/test/conftest.py +0 -0
  44. {pandahub-0.3.10 → pandahub-0.3.12}/test/performance_test.py +0 -0
  45. {pandahub-0.3.10 → pandahub-0.3.12}/test/test_client.py +0 -0
  46. {pandahub-0.3.10 → pandahub-0.3.12}/test/test_networks.py +0 -0
  47. {pandahub-0.3.10 → pandahub-0.3.12}/test/test_projects.py +0 -0
  48. {pandahub-0.3.10 → pandahub-0.3.12}/test/test_timeseries.py +0 -0
  49. {pandahub-0.3.10 → pandahub-0.3.12}/tutorials/config.py +0 -0
@@ -1,5 +1,9 @@
1
1
  # Change Log
2
2
 
3
+ ## [0.3.11]
4
+
5
+ - IMPROVED: add lib.database_toolbox.get_mongo_client function
6
+
3
7
  ## [0.3.10]
4
8
 
5
9
  - BREAKING: changed signatures of create_variant function and route
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pandahub
3
- Version: 0.3.10
3
+ Version: 0.3.12
4
4
  Summary: Data hub for pandapower and pandapipes networks based on MongoDB
5
5
  Author-email: Jan Ulffers <jan.ulffers@iee.fraunhofer.de>, Leon Thurner <leon.thurner@retoflow.de>, Jannis Kupka <jannis.kupka@retoflow.de>, Mike Vogt <mike.vogt@iee.fraunhofer.de>, Joschka Thurner <joschka.thurner@retoflow.de>, Alexander Scheidler <alexander.scheidler@iee.fraunhofer.de>
6
6
  License: Copyright (c) 2022 by University of Kassel, Fraunhofer Institute for Energy Economics
@@ -23,12 +23,14 @@ import pandapipes as pps
23
23
  from pandapipes import from_json_string as from_json_pps, FromSerializableRegistryPpipe
24
24
  import pandapower as pp
25
25
  import pandapower.io_utils as io_pp
26
+
26
27
  from pandahub.api.internal.settings import MONGODB_URL, MONGODB_USER, MONGODB_PASSWORD, MONGODB_GLOBAL_DATABASE_URL, \
27
28
  MONGODB_GLOBAL_DATABASE_USER, MONGODB_GLOBAL_DATABASE_PASSWORD, CREATE_INDEXES_WITH_PROJECT
28
29
  from pandahub.lib.database_toolbox import (
29
30
  create_timeseries_document,
30
31
  convert_timeseries_to_subdocuments,
31
32
  convert_element_to_dict,
33
+ get_mongo_client,
32
34
  json_to_object,
33
35
  serialize_object_data,
34
36
  get_dtypes,
@@ -77,6 +79,7 @@ class PandaHub:
77
79
  "read": ["owner", "developer", "guest"],
78
80
  "write": ["owner", "developer"],
79
81
  "user_management": ["owner"],
82
+ "delete_project": ["owner"],
80
83
  }
81
84
 
82
85
  # -------------------------
@@ -94,19 +97,9 @@ class PandaHub:
94
97
  mongodb_indexes=MONGODB_INDEXES,
95
98
  elements_without_vars = None,
96
99
  ):
97
- mongo_client_args = {
98
- "host": connection_url,
99
- "uuidRepresentation": "standard",
100
- "connect": False,
101
- }
102
- if connection_user:
103
- mongo_client_args |= {
104
- "username": connection_user,
105
- "password": connection_password,
106
- }
107
100
  self._datatypes = datatypes
108
101
  self.mongodb_indexes = mongodb_indexes
109
- self.mongo_client = MongoClient(**mongo_client_args)
102
+ self.mongo_client = get_mongo_client(connection_url, connection_user, connection_password)
110
103
  self.mongo_client_global_db = None
111
104
  self.active_project = None
112
105
  self.user_id = user_id
@@ -256,7 +249,7 @@ class PandaHub:
256
249
  if project_id:
257
250
  self.set_active_project_by_id(project_id)
258
251
  project_id = self.active_project["_id"]
259
- self.check_permission("write")
252
+ self.check_permission("delete_project")
260
253
  if not i_know_this_action_is_final:
261
254
  raise PandaHubError(
262
255
  "Calling this function will delete the whole project and all the nets stored within. It can not be reversed. Add 'i_know_this_action_is_final=True' to confirm."
@@ -2682,7 +2675,10 @@ class PandaHub:
2682
2675
  }
2683
2676
  pipeline.append({"$project": projection})
2684
2677
  if not include_metadata:
2685
- pipeline.append({"$project": {"timeseries_data": 1}})
2678
+ if compressed_ts_data:
2679
+ pipeline.append({"$project": {"timeseries_data": 1, "num_timestamps": 1}})
2680
+ else:
2681
+ pipeline.append({"$project": {"timeseries_data": 1}})
2686
2682
 
2687
2683
  timeseries = []
2688
2684
  for ts in db[collection_name].aggregate(pipeline):
@@ -2690,7 +2686,7 @@ class PandaHub:
2690
2686
  continue
2691
2687
  data = ts["timeseries_data"]
2692
2688
  if compressed_ts_data:
2693
- timeseries_data = decompress_timeseries_data(data, ts_format)
2689
+ timeseries_data = decompress_timeseries_data(data, ts_format, ts["num_timestamps"])
2694
2690
  ts["timeseries_data"] = timeseries_data
2695
2691
  else:
2696
2692
  if ts_format == "timestamp_value":
@@ -3,6 +3,9 @@ from typing import Optional
3
3
 
4
4
  import numpy as np
5
5
  import pandas as pd
6
+ from pymongo import MongoClient
7
+
8
+ from pandahub.api.internal.settings import MONGODB_URL, MONGODB_USER, MONGODB_PASSWORD
6
9
  from pandahub.lib.datatypes import DATATYPES
7
10
  import base64
8
11
  import hashlib
@@ -421,3 +424,17 @@ def migrate_userdb_to_beanie(ph):
421
424
  {'$unset': 'id'},
422
425
  {'$out': 'users'}]
423
426
  userdb.aggregate(migration)
427
+
428
+ def get_mongo_client(connection_url=MONGODB_URL, connection_user=MONGODB_USER,
429
+ connection_password=MONGODB_PASSWORD) -> MongoClient:
430
+ mongo_client_args = {
431
+ "host": connection_url,
432
+ "uuidRepresentation": "standard",
433
+ "connect": False,
434
+ }
435
+ if connection_user:
436
+ mongo_client_args |= {
437
+ "username": connection_user,
438
+ "password": connection_password,
439
+ }
440
+ return MongoClient(**mongo_client_args)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pandahub
3
- Version: 0.3.10
3
+ Version: 0.3.12
4
4
  Summary: Data hub for pandapower and pandapipes networks based on MongoDB
5
5
  Author-email: Jan Ulffers <jan.ulffers@iee.fraunhofer.de>, Leon Thurner <leon.thurner@retoflow.de>, Jannis Kupka <jannis.kupka@retoflow.de>, Mike Vogt <mike.vogt@iee.fraunhofer.de>, Joschka Thurner <joschka.thurner@retoflow.de>, Alexander Scheidler <alexander.scheidler@iee.fraunhofer.de>
6
6
  License: Copyright (c) 2022 by University of Kassel, Fraunhofer Institute for Energy Economics
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "pandahub"
7
- version = "0.3.10" # File format version '__format_version__' is tracked in __init__.py
7
+ version = "0.3.12" # File format version '__format_version__' is tracked in __init__.py
8
8
  authors=[
9
9
  { name = "Jan Ulffers", email = "jan.ulffers@iee.fraunhofer.de" },
10
10
  { name = "Leon Thurner", email = "leon.thurner@retoflow.de" },
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes