openforis-whisp 2.0.0a5__py3-none-any.whl → 2.0.0a6__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,75 +1,75 @@
1
- import ee
2
- from google.oauth2 import service_account
3
-
4
-
5
- def initialize_ee(credentials_path=None):
6
- """Initializes Google Earth Engine using the provided path or defaults to normal if no path is given."""
7
- try:
8
- if not ee.data._initialized:
9
- print(credentials_path)
10
- if credentials_path:
11
- credentials = service_account.Credentials.from_service_account_file(
12
- credentials_path,
13
- scopes=["https://www.googleapis.com/auth/earthengine"],
14
- )
15
- ee.Initialize(credentials)
16
- print("EE initialized with credentials from:", credentials_path)
17
- else:
18
- ee.Initialize()
19
- print("EE initialized with default credentials.")
20
- except Exception as e:
21
- print("Error initializing EE:", e)
22
-
23
-
24
- # Default to normal initialize if nobody calls whisp.initialize_ee.
25
- try:
26
- if not ee.data._initialized:
27
- ee.Initialize()
28
- print("EE auto-initialized with default credentials.")
29
- except Exception as e:
30
- print("Error in default EE initialization:", e)
31
-
32
- from openforis_whisp.datasets import (
33
- combine_datasets,
34
- )
35
-
36
- from openforis_whisp.stats import (
37
- whisp_stats_ee_to_ee,
38
- whisp_stats_ee_to_df,
39
- whisp_stats_geojson_to_df,
40
- whisp_stats_geojson_to_ee,
41
- whisp_stats_geojson_to_geojson,
42
- whisp_stats_ee_to_drive,
43
- whisp_stats_geojson_to_drive,
44
- whisp_formatted_stats_ee_to_df,
45
- whisp_formatted_stats_ee_to_geojson,
46
- whisp_formatted_stats_geojson_to_df,
47
- whisp_formatted_stats_geojson_to_geojson,
48
- convert_iso3_to_iso2,
49
- )
50
-
51
- # temporary parameters to be removed once isio3 to iso2 conversion server side is implemented
52
- from openforis_whisp.parameters.config_runtime import (
53
- iso3_country_column,
54
- iso2_country_column,
55
- )
56
-
57
- from openforis_whisp.reformat import (
58
- validate_dataframe_using_lookups,
59
- validate_dataframe,
60
- create_schema_from_dataframe,
61
- load_schema_if_any_file_changed,
62
- # log_missing_columns,
63
- )
64
-
65
- from openforis_whisp.data_conversion import (
66
- convert_ee_to_df,
67
- convert_geojson_to_ee,
68
- convert_df_to_geojson,
69
- convert_csv_to_geojson,
70
- convert_ee_to_geojson,
71
- )
72
-
73
- from openforis_whisp.risk import whisp_risk, detect_unit_type
74
-
75
- from openforis_whisp.utils import get_example_data_path
1
+ import ee
2
+ from google.oauth2 import service_account
3
+
4
+
5
+ def initialize_ee(credentials_path=None):
6
+ """Initializes Google Earth Engine using the provided path or defaults to normal if no path is given."""
7
+ try:
8
+ if not ee.data._initialized:
9
+ print(credentials_path)
10
+ if credentials_path:
11
+ credentials = service_account.Credentials.from_service_account_file(
12
+ credentials_path,
13
+ scopes=["https://www.googleapis.com/auth/earthengine"],
14
+ )
15
+ ee.Initialize(credentials)
16
+ print("EE initialized with credentials from:", credentials_path)
17
+ else:
18
+ ee.Initialize()
19
+ print("EE initialized with default credentials.")
20
+ except Exception as e:
21
+ print("Error initializing EE:", e)
22
+
23
+
24
+ # Default to normal initialize if nobody calls whisp.initialize_ee.
25
+ try:
26
+ if not ee.data._initialized:
27
+ ee.Initialize()
28
+ print("EE auto-initialized with default credentials.")
29
+ except Exception as e:
30
+ print("Error in default EE initialization:", e)
31
+
32
+ from openforis_whisp.datasets import (
33
+ combine_datasets,
34
+ )
35
+
36
+ from openforis_whisp.stats import (
37
+ whisp_stats_ee_to_ee,
38
+ whisp_stats_ee_to_df,
39
+ whisp_stats_geojson_to_df,
40
+ whisp_stats_geojson_to_ee,
41
+ whisp_stats_geojson_to_geojson,
42
+ whisp_stats_ee_to_drive,
43
+ whisp_stats_geojson_to_drive,
44
+ whisp_formatted_stats_ee_to_df,
45
+ whisp_formatted_stats_ee_to_geojson,
46
+ whisp_formatted_stats_geojson_to_df,
47
+ whisp_formatted_stats_geojson_to_geojson,
48
+ convert_iso3_to_iso2,
49
+ )
50
+
51
+ # temporary parameters to be removed once isio3 to iso2 conversion server side is implemented
52
+ from openforis_whisp.parameters.config_runtime import (
53
+ iso3_country_column,
54
+ iso2_country_column,
55
+ )
56
+
57
+ from openforis_whisp.reformat import (
58
+ validate_dataframe_using_lookups,
59
+ validate_dataframe,
60
+ create_schema_from_dataframe,
61
+ load_schema_if_any_file_changed,
62
+ # log_missing_columns,
63
+ )
64
+
65
+ from openforis_whisp.data_conversion import (
66
+ convert_ee_to_df,
67
+ convert_geojson_to_ee,
68
+ convert_df_to_geojson,
69
+ convert_csv_to_geojson,
70
+ convert_ee_to_geojson,
71
+ )
72
+
73
+ from openforis_whisp.risk import whisp_risk, detect_unit_type
74
+
75
+ from openforis_whisp.utils import get_example_data_path