Skip to content

Commit ac0e6f0

Browse files
committed
updated v0.6.2
- Removed call to shell - Now prints status of task at task creation - Overwrite option for both images and tables
1 parent 1d519c1 commit ac0e6f0

File tree

6 files changed

+33
-37
lines changed

6 files changed

+33
-37
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,11 @@ optional arguments:
339339

340340
# Changelog
341341

342+
### 0.6.2
343+
- Removed call to shell
344+
- Now prints status of task at task creation
345+
- Overwrite option for both images and tables
346+
342347
### 0.6.1
343348
- Removed dependency on pipwin uses pipgeo instead
344349
- Removed dependency on beautifulsoup

docs/changelog.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
### 0.6.2
4+
- Removed call to shell
5+
- Now prints status of task at task creation
6+
- Overwrite option for both images and tables
7+
38
### 0.6.1
49
- Removed dependency on pipwin uses pipgeo instead
510
- Removed dependency on beautifulsoup

geeup/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
__author__ = "Samapriya Roy"
44
__email__ = "[email protected]"
5-
__version__ = "0.6.1"
5+
__version__ = "0.6.2"

geeup/batch_uploader.py

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -240,21 +240,16 @@ def upload(
240240
if v.validate(asset_validate, schema) is False:
241241
print(v.errors)
242242
raise Exception
243-
with open(os.path.join(lp, "data.json"), "w") as outfile:
244-
json.dump(main_payload, outfile)
243+
request_id = ee.data.newTaskId()[0]
245244
check_list = ['yes', 'y']
246245
if overwrite is not None and overwrite.lower() in check_list:
247-
output = subprocess.check_output(
248-
f"earthengine upload image --manifest {os.path.join(lp, 'data.json')} -f",
249-
shell=True
250-
)
246+
output = ee.data.startIngestion(
247+
request_id, main_payload, allow_overwrite=True)
251248
else:
252-
output = subprocess.check_output(
253-
f"earthengine upload image --manifest {os.path.join(lp, 'data.json')}",
254-
shell=True
255-
)
249+
output = ee.data.startIngestion(
250+
request_id, main_payload, allow_overwrite=False)
256251
logging.info(
257-
f"Ingesting {current_image_no+1} of {file_count} {str(os.path.basename(asset_full_path))} with Task Id: {output.decode('ascii').strip().split(' ')[-1]}"
252+
f"Ingesting {current_image_no+1} of {file_count} {str(os.path.basename(asset_full_path))} with Task Id: {output['id']} & status {output['started']}"
258253
)
259254
except Exception as error:
260255
print(error)

geeup/tuploader.py

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
__copyright__ = """
22
3-
Copyright 2022 Samapriya Roy
3+
Copyright 2023 Samapriya Roy
44
55
Licensed under the Apache License, Version 2.0 (the "License");
66
you may not use this file except in compliance with the License.
@@ -269,22 +269,15 @@ def tabup(dirc, uname, destination, x, y, overwrite=None):
269269
if v.validate(asset_validate, schema) is False:
270270
print(v.errors)
271271
raise Exception
272-
with open(
273-
os.path.join(lp, "data.json"), "w"
274-
) as outfile:
275-
json.dump(main_payload, outfile)
272+
request_id = ee.data.newTaskId()[0]
276273
if overwrite is not None and overwrite.lower() in check_list:
277-
output = subprocess.check_output(
278-
f"earthengine upload table --manifest {os.path.join(lp, 'data.json')} -f",
279-
shell=True
280-
)
274+
output = ee.data.startTableIngestion(
275+
request_id, main_payload, allow_overwrite=True)
281276
else:
282-
output = subprocess.check_output(
283-
f"earthengine upload table --manifest {os.path.join(lp, 'data.json')}",
284-
shell=True
285-
)
277+
output = ee.data.startTableIngestion(
278+
request_id, main_payload, allow_overwrite=False)
286279
logging.info(
287-
f"Ingesting {i+1} of {file_count} {str(os.path.basename(asset_full_path))} with Task Id: {output.decode('ascii').strip().split(' ')[-1]}"
280+
f"Ingesting {i+1} of {file_count} {str(os.path.basename(asset_full_path))} with Task Id: {output['id']} & status {output['started']}"
288281
)
289282
elif base_ext == ".csv":
290283
m = MultipartEncoder(
@@ -337,17 +330,15 @@ def tabup(dirc, uname, destination, x, y, overwrite=None):
337330
if v.validate(asset_validate, schema) is False:
338331
print(v.errors)
339332
raise Exception
340-
with open(
341-
os.path.join(lp, "data.json"), "w"
342-
) as outfile:
343-
json.dump(main_payload, outfile)
344-
manifest_file = os.path.join(lp, "data.json")
345-
output = subprocess.check_output(
346-
f"earthengine upload table --manifest {manifest_file}",
347-
shell=True,
348-
)
333+
request_id = ee.data.newTaskId()[0]
334+
if overwrite is not None and overwrite.lower() in check_list:
335+
output = ee.data.startTableIngestion(
336+
request_id, main_payload, allow_overwrite=True)
337+
else:
338+
output = ee.data.startTableIngestion(
339+
request_id, main_payload, allow_overwrite=False)
349340
logging.info(
350-
f"Ingesting {i+1} of {file_count} {str(os.path.basename(asset_full_path))} with Task Id: {output.decode('ascii').strip().split(' ')[-1]}"
341+
f"Ingesting {i+1} of {file_count} {str(os.path.basename(asset_full_path))} with Task Id: {output['id']} & status {output['started']}"
351342
)
352343
except Exception as error:
353344
print(error)

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def readme():
1515

1616
setuptools.setup(
1717
name="geeup",
18-
version="0.6.1",
18+
version="0.6.2",
1919
packages=find_packages(),
2020
url="https://github.com/samapriya/geeup",
2121
install_requires=[

0 commit comments

Comments
 (0)