hestia-earth-utils 0.16.16__py3-none-any.whl → 0.16.18__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.
@@ -1,3 +1,4 @@
1
+ import os
1
2
  from os.path import join
2
3
  import json
3
4
  import numpy as np
@@ -375,3 +376,29 @@ def get_related_nodes_data(
375
376
  }
376
377
  for node in related_nodes
377
378
  ]
379
+
380
+
381
+ def start_instances(multiple_instances: bool = False):
382
+ import boto3
383
+
384
+ client = boto3.client("ec2")
385
+ instance_ids = os.getenv("START_INSTANCE_ID").split(",")
386
+ ids = instance_ids if multiple_instances else [instance_ids[0]]
387
+ try:
388
+ for instance_id in ids:
389
+ response = client.describe_instances(InstanceIds=[instance_id])
390
+ state = response["Reservations"][0]["Instances"][0]["State"]["Name"]
391
+ print(f"Checking {instance_id}: Current state is '{state}'")
392
+
393
+ if state in ["pending", "running"]:
394
+ print(f" -> Instance {instance_id} is already active. Skipping.")
395
+ continue
396
+
397
+ elif state == "stopped":
398
+ print(f" -> Instance {instance_id} is stopped. Starting it now...")
399
+ client.start_instances(InstanceIds=[instance_id])
400
+ break
401
+ except client.exceptions.ClientError as e:
402
+ print(f"Error starting instances: {str(e)}")
403
+
404
+ print("Could not start any instance")
@@ -51,6 +51,13 @@ def _combine_node_ids(nodes: list):
51
51
  return {"@id": ";".join([node.get("@id", node.get("id")) for node in nodes])}
52
52
 
53
53
 
54
+ _COMPACT_JSON_KEYS = ["boundary", "distribution", "covarianceMatrix"]
55
+
56
+
57
+ def _combine_json_compact(key: str, value: dict):
58
+ return json.dumps(value).replace(" ", "") if key in _COMPACT_JSON_KEYS else value
59
+
60
+
54
61
  def _base_pivoted_value(key: str, value, is_top_level: bool):
55
62
  # handle list of Nodes
56
63
  return (
@@ -58,13 +65,13 @@ def _base_pivoted_value(key: str, value, is_top_level: bool):
58
65
  _combine_node_ids(value)
59
66
  if isinstance(value[0], dict) and value[0].get("@type") in NODE_TYPES
60
67
  else (
61
- json.dumps(value, separators=(",", ":"))
62
- if any([is_top_level, key in ["distribution"]])
68
+ _combine_json_compact(key, value)
69
+ if any([is_top_level, key in _COMPACT_JSON_KEYS])
63
70
  else value
64
71
  )
65
72
  )
66
73
  if isinstance(value, list)
67
- else value
74
+ else _combine_json_compact(key, value)
68
75
  )
69
76
 
70
77
 
@@ -1 +1 @@
1
- VERSION = "0.16.16"
1
+ VERSION = "0.16.18"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hestia_earth_utils
3
- Version: 0.16.16
3
+ Version: 0.16.18
4
4
  Summary: HESTIA's utils library
5
5
  Home-page: https://gitlab.com/hestia-earth/hestia-utils
6
6
  Author: HESTIA Team
@@ -9,25 +9,25 @@ hestia_earth/utils/emission.py,sha256=rHHf5vwe-RxTOaOJ9N0MuyJOLpDnPjjxv6MHYSpPgc
9
9
  hestia_earth/utils/lookup.py,sha256=SArKqjqs_Yt5cC6TIk12WVQNToun2spZ_iNUm4fX9FA,8274
10
10
  hestia_earth/utils/lookup_utils.py,sha256=cjYIFSQpcdSCoHqCoz3f5Odkpv_2j5aGn0COOIdz3hg,6948
11
11
  hestia_earth/utils/model.py,sha256=YzQ4Cs3HBlhLGNDvrfv2pM_FrNZhZkg9h7JKIH3CHFE,4626
12
- hestia_earth/utils/pipeline.py,sha256=LYxPXhuSWTwmsLRz_nl_JscFgGYhUAbNQx4Zla5_REM,10292
12
+ hestia_earth/utils/pipeline.py,sha256=EvZKSCle3bFNfy1slD24-4dcziiFuW-e_3Re2liaYao,11319
13
13
  hestia_earth/utils/request.py,sha256=EfitmS13abPxfl5gSAOyHRUYhk4R2Rfv94fF9lvOT00,723
14
14
  hestia_earth/utils/stats.py,sha256=vTNyKcMKmX0DoodM9QEG7HF8qm2Wf-4ckMWQFWZ1VgE,34729
15
15
  hestia_earth/utils/table.py,sha256=MOJDo5fQPRDogAty_UXbO9-EXFwz97m0f7--mOM17lQ,2363
16
16
  hestia_earth/utils/term.py,sha256=aBVYuYv55nPqJPyt5mN4Fz652s_1hwUPckNUZX0pMP8,1064
17
17
  hestia_earth/utils/tools.py,sha256=WMx05cBtBR8mYQnLLBA2cgF1x2tI41514diFDeX4gLQ,7533
18
- hestia_earth/utils/version.py,sha256=SGKvksJDyfirCQnk3wbuotlbC2CvazXTR8lJe6kBC6U,20
18
+ hestia_earth/utils/version.py,sha256=GRD_WbP1hGteFSYD0I4Y_A4gXGnyzTXUqqTJ4jRXspM,20
19
19
  hestia_earth/utils/pivot/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
20
20
  hestia_earth/utils/pivot/_shared.py,sha256=ZBmZRLbDN2JHODvQAh9jH_61Koh7Ts0C52xmiw_Bhpo,2827
21
21
  hestia_earth/utils/pivot/pivot_csv.py,sha256=1zGYuC_xlrLoX5FYSG3mt5HSc03CO-0p8J0oAmyI1VI,11778
22
- hestia_earth/utils/pivot/pivot_json.py,sha256=yWbsuFeTQJPk4H2b7ibVALGJa3qfKGyNuPeqM8yrcsI,11030
22
+ hestia_earth/utils/pivot/pivot_json.py,sha256=bqR3SmoHu9-Ij4UtUEbsZjEqtqq1jdS4Nx3CpyLN3Mc,11263
23
23
  hestia_earth/utils/storage/__init__.py,sha256=uNX6_EHWWnNUIm4Ng7L43-cQmuc6NGFAxXye85saIXQ,922
24
24
  hestia_earth/utils/storage/_azure_client.py,sha256=mseexhzjteRDzzoFe2fEXe9MYLmvjG3sfl9-eha4ZW0,1353
25
25
  hestia_earth/utils/storage/_local_client.py,sha256=KbYqTfniIU5R5J1m_unCQip9kOz9EGIGI0OH0QvD8eo,551
26
26
  hestia_earth/utils/storage/_s3_client.py,sha256=8TCxiHfxE7G8kdp3CnEFrxgmPwfPyci3-blsowE2T7o,3146
27
27
  hestia_earth/utils/storage/_sns_client.py,sha256=pvtXYw-sQ8ns3mlDz7ld9iZp3FYSm0xSXSXMJ5IPnBc,380
28
- hestia_earth_utils-0.16.16.data/scripts/hestia-format-upload,sha256=IhLAHHPJqRgUcht-M_EUEsRMbRbMfshig07o488zscM,703
29
- hestia_earth_utils-0.16.16.data/scripts/hestia-pivot-csv,sha256=0YBuGuyPO8rytod6iwWEKiQdSlr9JLuD001k6U5t6no,1163
30
- hestia_earth_utils-0.16.16.dist-info/METADATA,sha256=iOf4uwvgxtoZgFdSjW3uElhZfRf9vRQFJL_LC9ojvlM,1873
31
- hestia_earth_utils-0.16.16.dist-info/WHEEL,sha256=qELbo2s1Yzl39ZmrAibXA2jjPLUYfnVhUNTlyF1rq0Y,92
32
- hestia_earth_utils-0.16.16.dist-info/top_level.txt,sha256=q0QxKEYx9uLpAD5ZtC7Ypq29smEPfOzEAn7Xv8XHGOQ,13
33
- hestia_earth_utils-0.16.16.dist-info/RECORD,,
28
+ hestia_earth_utils-0.16.18.data/scripts/hestia-format-upload,sha256=IhLAHHPJqRgUcht-M_EUEsRMbRbMfshig07o488zscM,703
29
+ hestia_earth_utils-0.16.18.data/scripts/hestia-pivot-csv,sha256=0YBuGuyPO8rytod6iwWEKiQdSlr9JLuD001k6U5t6no,1163
30
+ hestia_earth_utils-0.16.18.dist-info/METADATA,sha256=p-XSakIkjWkzvUUUU2dgegRFRWBm0ip0sfINgSBI7aM,1873
31
+ hestia_earth_utils-0.16.18.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
32
+ hestia_earth_utils-0.16.18.dist-info/top_level.txt,sha256=q0QxKEYx9uLpAD5ZtC7Ypq29smEPfOzEAn7Xv8XHGOQ,13
33
+ hestia_earth_utils-0.16.18.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.10.1)
2
+ Generator: setuptools (80.10.2)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5