atlasai-dstoolkit-client 0.0.14__py3-none-any.whl → 0.0.16__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.
- atlasai/toolkit/constants.py +7 -0
- atlasai/toolkit/workflows.py +73 -9
- {atlasai_dstoolkit_client-0.0.14.dist-info → atlasai_dstoolkit_client-0.0.16.dist-info}/METADATA +3 -1
- {atlasai_dstoolkit_client-0.0.14.dist-info → atlasai_dstoolkit_client-0.0.16.dist-info}/RECORD +7 -7
- {atlasai_dstoolkit_client-0.0.14.dist-info → atlasai_dstoolkit_client-0.0.16.dist-info}/LICENSE.txt +0 -0
- {atlasai_dstoolkit_client-0.0.14.dist-info → atlasai_dstoolkit_client-0.0.16.dist-info}/WHEEL +0 -0
- {atlasai_dstoolkit_client-0.0.14.dist-info → atlasai_dstoolkit_client-0.0.16.dist-info}/top_level.txt +0 -0
atlasai/toolkit/constants.py
CHANGED
@@ -11,3 +11,10 @@ DISABLE_SSL_VERIFICATION = 'DISABLE_SSL_VERIFICATION'
|
|
11
11
|
|
12
12
|
TOKEN_ENV_VAR = 'VINZ_ENCRYPTED_TOKEN'
|
13
13
|
TOKEN_TIMESTAMP_ENV_VAR = 'VINZ_ENCRYPTED_TOKEN_TIMESTAMP'
|
14
|
+
|
15
|
+
LEAFMAP_COLORMAP = [
|
16
|
+
"viridis", "plasma", "inferno", "magma", "cividis",
|
17
|
+
"Greys", "Purples", "Blues", "Greens", "Oranges", "Reds",
|
18
|
+
"YlOrBr", "YlOrRd", "OrRd", "PuRd", "RdPu", "BuPu", "GnBu", "PuBu",
|
19
|
+
"YlGnBu", "PuBuGn", "BuGn", "YlGn"
|
20
|
+
]
|
atlasai/toolkit/workflows.py
CHANGED
@@ -11,19 +11,21 @@
|
|
11
11
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
|
+
import ast
|
15
|
+
from concurrent.futures import ThreadPoolExecutor, as_completed
|
16
|
+
from dataclasses import dataclass
|
17
|
+
from datetime import datetime
|
14
18
|
import logging
|
15
19
|
import os
|
20
|
+
import random
|
16
21
|
import time
|
17
22
|
|
23
|
+
import leafmap
|
18
24
|
import pandas as pd
|
19
|
-
from tqdm import tqdm
|
20
|
-
|
21
|
-
from concurrent.futures import ThreadPoolExecutor, as_completed
|
22
|
-
from dataclasses import dataclass
|
23
|
-
|
24
25
|
import requests
|
26
|
+
from tqdm import tqdm
|
25
27
|
|
26
|
-
from . import api, output as o
|
28
|
+
from . import api, constants, output as o
|
27
29
|
|
28
30
|
logger = logging.getLogger('atlasai.toolkit')
|
29
31
|
|
@@ -45,6 +47,7 @@ class Workflow:
|
|
45
47
|
def __init__(self, id=None):
|
46
48
|
# Allow the selection of an existing workflow and check the logs.
|
47
49
|
self.id = id
|
50
|
+
self.results = []
|
48
51
|
|
49
52
|
@property
|
50
53
|
def status(self):
|
@@ -66,6 +69,9 @@ class Workflow:
|
|
66
69
|
def _results(self, *args, **kwargs):
|
67
70
|
raise NotImplementedError
|
68
71
|
|
72
|
+
def preview(self, *args, **kwargs):
|
73
|
+
raise NotImplementedError
|
74
|
+
|
69
75
|
def get(self):
|
70
76
|
if not self.id:
|
71
77
|
raise Exception('No valid execution of the workflow. Please use the `run` method first.')
|
@@ -74,6 +80,11 @@ class Workflow:
|
|
74
80
|
return result
|
75
81
|
|
76
82
|
def logs(self, only_errors=True):
|
83
|
+
def cleanup_logs(logs):
|
84
|
+
if not logs:
|
85
|
+
return "-"
|
86
|
+
return ast.literal_eval(logs).decode('utf-8')
|
87
|
+
|
77
88
|
if not self.id:
|
78
89
|
raise Exception('No valid execution of the workflow. Please use the `run` method first.')
|
79
90
|
|
@@ -86,7 +97,6 @@ class Workflow:
|
|
86
97
|
o.print_subtitle(f'Message: {workflow["data"]["message"] or "-"}')
|
87
98
|
|
88
99
|
o.print_body('---------------------------------------------------')
|
89
|
-
|
90
100
|
if not result['data']:
|
91
101
|
if only_errors:
|
92
102
|
o.print_title('No errors detected.')
|
@@ -96,7 +106,7 @@ class Workflow:
|
|
96
106
|
for pod, data in result['data'].items():
|
97
107
|
o.print_title(f'Pod: {pod}')
|
98
108
|
o.print_subtitle(f'Message: {data["message"] or "-"}')
|
99
|
-
o.print_subtitle(f'Logs: {data
|
109
|
+
o.print_subtitle(f'Logs: {cleanup_logs(data.get("logs"))}')
|
100
110
|
o.print_body('---------------------------------------------------')
|
101
111
|
|
102
112
|
def run(self, wait_until_complete=False):
|
@@ -182,6 +192,9 @@ class Electrification(Workflow):
|
|
182
192
|
raise Exception('`aoi_path` or `aoi` must be specified.')
|
183
193
|
|
184
194
|
def _results(self, save_to=None):
|
195
|
+
if self.results:
|
196
|
+
return self.results
|
197
|
+
|
185
198
|
results = []
|
186
199
|
if not self.id:
|
187
200
|
raise Exception('No valid execution of the workflow. Please use the `run` method first.')
|
@@ -198,7 +211,7 @@ class Electrification(Workflow):
|
|
198
211
|
for fut in as_completed(fut_map):
|
199
212
|
results.append(fut.result())
|
200
213
|
pbar.update(1)
|
201
|
-
|
214
|
+
self.results = results
|
202
215
|
return results
|
203
216
|
|
204
217
|
def _download_file(self, name, url, to=None):
|
@@ -219,6 +232,57 @@ class Electrification(Workflow):
|
|
219
232
|
|
220
233
|
return local_path
|
221
234
|
|
235
|
+
def preview(self, from_=None, to_=None, selection=None, limit=None):
|
236
|
+
if not self.results:
|
237
|
+
raise Exception('No result to be displayed. Run the workflow first and wait for its completion.')
|
238
|
+
_results = []
|
239
|
+
if selection is None:
|
240
|
+
selection = []
|
241
|
+
if selection:
|
242
|
+
selection = ['-'.join(s.split('-')[:2]) for s in selection]
|
243
|
+
from_, to_, limit = None, None, None
|
244
|
+
|
245
|
+
if from_:
|
246
|
+
from_ = datetime.strptime(from_, "%Y-%m-%d")
|
247
|
+
if to_:
|
248
|
+
to_ = datetime.strptime(to_, "%Y-%m-%d")
|
249
|
+
|
250
|
+
for f in sorted(self.results):
|
251
|
+
yyyy, mm = f.split('_')[-1].replace('.tif', '').split('-')
|
252
|
+
dt = datetime(year=int(yyyy), month=int(mm), day=1)
|
253
|
+
if selection:
|
254
|
+
if f'{yyyy}-{mm}' not in selection:
|
255
|
+
continue
|
256
|
+
if from_ and from_ > dt:
|
257
|
+
continue
|
258
|
+
if to_ and to_ < dt:
|
259
|
+
continue
|
260
|
+
if limit and len(_results) >= limit:
|
261
|
+
continue
|
262
|
+
_results.append(dict(
|
263
|
+
layer_name=f'{yyyy}-{mm}',
|
264
|
+
file=f,
|
265
|
+
colormap=constants.LEAFMAP_COLORMAP[random.randint(0, len(constants.LEAFMAP_COLORMAP) - 1)]
|
266
|
+
))
|
267
|
+
if not _results:
|
268
|
+
raise Exception('No result matches your criteria.')
|
269
|
+
m = leafmap.Map()
|
270
|
+
if len(_results) > 10:
|
271
|
+
logger.warning(f'Too many layers to display. Expect increased loading time. Layers to display: {len(_results)}')
|
272
|
+
|
273
|
+
for idx, f in enumerate(_results):
|
274
|
+
m.add_raster(
|
275
|
+
f['file'],
|
276
|
+
layer_name=f['layer_name'],
|
277
|
+
nodata=0,
|
278
|
+
colormap=f['colormap'],
|
279
|
+
opacity=0.5,
|
280
|
+
)
|
281
|
+
if hasattr(m, "add_layers_control"):
|
282
|
+
m.add_layers_control()
|
283
|
+
elif hasattr(m, "add_layer_control"):
|
284
|
+
m.add_layer_control()
|
285
|
+
return m
|
222
286
|
|
223
287
|
def List(search=None, offset=0, limit=100):
|
224
288
|
pd.set_option("display.max_colwidth", None)
|
{atlasai_dstoolkit_client-0.0.14.dist-info → atlasai_dstoolkit_client-0.0.16.dist-info}/METADATA
RENAMED
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: atlasai-dstoolkit-client
|
3
|
-
Version: 0.0.
|
3
|
+
Version: 0.0.16
|
4
4
|
Summary: UNKNOWN
|
5
5
|
Home-page: UNKNOWN
|
6
6
|
Author: AtlasAI SWE
|
@@ -13,6 +13,8 @@ Requires-Dist: arrow (<2.0.0,>=1.3.0)
|
|
13
13
|
Requires-Dist: atlasai-mlhub-client
|
14
14
|
Requires-Dist: furl (<3.0.0,>=2.1.2)
|
15
15
|
Requires-Dist: geopandas (~=1.1.1)
|
16
|
+
Requires-Dist: leafmap (~=0.52.0)
|
17
|
+
Requires-Dist: localtileserver (~=0.10.6)
|
16
18
|
Requires-Dist: pandas (<3.0.0,>=2.2.3)
|
17
19
|
Requires-Dist: pyarrow (>=19.0.1)
|
18
20
|
Requires-Dist: python-dotenv (<2.0.0,>=1.0.1)
|
{atlasai_dstoolkit_client-0.0.14.dist-info → atlasai_dstoolkit_client-0.0.16.dist-info}/RECORD
RENAMED
@@ -1,6 +1,6 @@
|
|
1
1
|
atlasai/toolkit/__init__.py,sha256=0d2EYTgFf-RH2z1M83gGfZdrt_PBXbJk6o5ZVAKCPtA,1013
|
2
2
|
atlasai/toolkit/api.py,sha256=BvO-gLRmbmkKduwbbADjcLlIkS9blzfM_cbMR4DhQmU,5269
|
3
|
-
atlasai/toolkit/constants.py,sha256=
|
3
|
+
atlasai/toolkit/constants.py,sha256=fCVI3Q6g28uCQJsY10BUsb301TO9_W0OqWdd9QwZrfg,675
|
4
4
|
atlasai/toolkit/dataset.py,sha256=fhzhxF9YMzIwEpaJZEPOK2SuLMJhVGI75eahxnH_T2c,3254
|
5
5
|
atlasai/toolkit/fabric.py,sha256=6aFR2PGQc9P3Qa07WdBg9eKoUzU8n2y_-gGjYcyMrWY,1921
|
6
6
|
atlasai/toolkit/feature.py,sha256=Q5M9zOGafynYuKaELL1kZemYPfKAZh84TgH7jw9J3ZU,2949
|
@@ -10,9 +10,9 @@ atlasai/toolkit/model.py,sha256=RUe0HbDpzvHOV9A4rzG3PgN9boMWDHQ2tR7IKHXzbx8,4126
|
|
10
10
|
atlasai/toolkit/output.py,sha256=FyDjrpVlbrEyfHfwOpxp8H57jx_qXahDjO1qpHIeuYM,473
|
11
11
|
atlasai/toolkit/requests.py,sha256=X86nIo07hAjUlilZcZ1lV8RB7KOsTKbTGtcY_SpFEXY,1223
|
12
12
|
atlasai/toolkit/utils.py,sha256=lYh3P2XOshRgHCjFeXJ0FOJWQW64sddgx8c2kL6Wqwc,1566
|
13
|
-
atlasai/toolkit/workflows.py,sha256=
|
14
|
-
atlasai_dstoolkit_client-0.0.
|
15
|
-
atlasai_dstoolkit_client-0.0.
|
16
|
-
atlasai_dstoolkit_client-0.0.
|
17
|
-
atlasai_dstoolkit_client-0.0.
|
18
|
-
atlasai_dstoolkit_client-0.0.
|
13
|
+
atlasai/toolkit/workflows.py,sha256=u17Hl-tIgyoB_-dA23g5h2o900fcsyj3H1uVVbZ4Mao,9392
|
14
|
+
atlasai_dstoolkit_client-0.0.16.dist-info/LICENSE.txt,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
|
15
|
+
atlasai_dstoolkit_client-0.0.16.dist-info/METADATA,sha256=cC7U97hGZ68zR7Gapl1ZXPR2R2Q2Y4Xyp7--UtfdOnM,1547
|
16
|
+
atlasai_dstoolkit_client-0.0.16.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
|
17
|
+
atlasai_dstoolkit_client-0.0.16.dist-info/top_level.txt,sha256=HRTbErU8nmHFDaJJ5R_XYbwpt21dqdjDpSva8xyy_0k,8
|
18
|
+
atlasai_dstoolkit_client-0.0.16.dist-info/RECORD,,
|
{atlasai_dstoolkit_client-0.0.14.dist-info → atlasai_dstoolkit_client-0.0.16.dist-info}/LICENSE.txt
RENAMED
File without changes
|
{atlasai_dstoolkit_client-0.0.14.dist-info → atlasai_dstoolkit_client-0.0.16.dist-info}/WHEEL
RENAMED
File without changes
|
File without changes
|