From 852d1b8b97d8908e9d5fa574d58c8cd7f59c7e09 Mon Sep 17 00:00:00 2001 From: Samweli Date: Thu, 12 Sep 2024 12:34:45 +0300 Subject: [PATCH 1/2] interim work on adding parallel processing using QgsTask --- LDMP/calculate_drought_vulnerability.py | 10 ++++-- LDMP/calculate_lc.py | 25 +++++++++++--- LDMP/calculate_ldn.py | 20 +++++++++-- LDMP/calculate_prod.py | 11 ++++-- LDMP/calculate_rest_biomass.py | 11 ++++-- LDMP/calculate_soc.py | 8 ++++- LDMP/calculate_tc.py | 12 +++++-- LDMP/calculate_unccd.py | 10 ++++-- LDMP/calculate_urban.py | 10 ++++-- LDMP/download_data.py | 13 +++++-- LDMP/jobs/models.py | 2 +- LDMP/landpks.py | 11 ++++-- LDMP/tasks.py | 46 +++++++++++++++++++++++++ LDMP/timeseries.py | 10 ++++-- 14 files changed, 172 insertions(+), 27 deletions(-) create mode 100644 LDMP/tasks.py diff --git a/LDMP/calculate_drought_vulnerability.py b/LDMP/calculate_drought_vulnerability.py index 1d5c2f61c..85f0104a4 100644 --- a/LDMP/calculate_drought_vulnerability.py +++ b/LDMP/calculate_drought_vulnerability.py @@ -18,13 +18,14 @@ import qgis.gui from qgis.core import QgsGeometry from qgis.PyQt import QtCore, QtWidgets, uic -from te_schemas.algorithms import ExecutionScript +from te_schemas.algorithms import AlgorithmRunMode, ExecutionScript from . import conf from .calculate import DlgCalculateBase from .jobs.manager import job_manager from .localexecution import drought from .logger import log +from .tasks import create_task DlgCalculateDroughtUi, _ = uic.loadUiType( str(Path(__file__).parent / "gui/DlgCalculateDrought.ui") @@ -145,7 +146,12 @@ def btn_calculate(self): self.close() - resp = job_manager.submit_remote_job(payload, self.script.id) + resp = create_task( + job_manager, + payload, + self.script.id, + AlgorithmRunMode.REMOTE, + ) if resp: main_msg = "Submitted" diff --git a/LDMP/calculate_lc.py b/LDMP/calculate_lc.py index 5fc42b913..bb4391b36 100644 --- a/LDMP/calculate_lc.py +++ b/LDMP/calculate_lc.py @@ -10,7 +10,7 @@ email : trends.earth@conservation.org ***************************************************************************/ """ - +import functools import json from pathlib import Path @@ -21,6 +21,7 @@ from te_schemas.land_cover import LCLegendNesting, LCTransitionDefinitionDeg from . import calculate, lc_setup +from .tasks import create_task from .jobs.manager import job_manager DlgCalculateLcUi, _ = uic.loadUiType( @@ -97,9 +98,17 @@ def calculate_on_GEE(self): "task_name": self.execution_name_le.text(), "task_notes": self.task_notes.toPlainText(), } - job = job_manager.submit_remote_job(payload, self.script.id) - if job is not None: + create_task( + job_manager, + payload, + self.script.id, + AlgorithmRunMode.REMOTE, + self.job_submitted + ) + + def job_submitted(self, exception, result=None): + if result is not None: main_msg = "Submitted" description = "Land cover task submitted to Trends.Earth server." else: @@ -206,4 +215,12 @@ def calculate_locally(self): "legend_nesting": initial_nesting, "trans_matrix": LCTransitionDefinitionDeg.Schema().dumps(trans_matrix), } - job_manager.submit_local_job(job_params, self.LOCAL_SCRIPT_NAME, self.aoi) + + create_task( + job_manager, + job_params, + self.LOCAL_SCRIPT_NAME, + AlgorithmRunMode.LOCAL, + self.aoi + ) + diff --git a/LDMP/calculate_ldn.py b/LDMP/calculate_ldn.py index 98472082a..78f75d4e8 100644 --- a/LDMP/calculate_ldn.py +++ b/LDMP/calculate_ldn.py @@ -20,10 +20,12 @@ import te_algorithms.gdal.land_deg.config as ld_config from qgis.core import QgsGeometry from qgis.PyQt import QtCore, QtWidgets, uic -from te_schemas.algorithms import ExecutionScript +from te_schemas.algorithms import AlgorithmRunMode, ExecutionScript from te_schemas.land_cover import LCLegendNesting, LCTransitionDefinitionDeg from te_schemas.productivity import ProductivityMode + +from .tasks import create_task from . import conf, lc_setup from .calculate import DlgCalculateBase from .jobs.manager import job_manager @@ -623,7 +625,13 @@ def btn_calculate(self): self.close() for payload in payloads: - resp = job_manager.submit_remote_job(payload, self.script.id) + + resp = create_task( + job_manager, + payload, + self.script.id, + AlgorithmRunMode.REMOTE + ) if resp: main_msg = "Submitted" @@ -1212,7 +1220,13 @@ def btn_calculate(self): # # self.close() # - # resp = job_manager.submit_remote_job(payload, self.script.id) + + # resp = create_task( + # job_manager, + # payload, + # self.script.id, + # AlgorithmRunMode.REMOTE, + # ) # # if resp: # main_msg = "Submitted" diff --git a/LDMP/calculate_prod.py b/LDMP/calculate_prod.py index 39339e8b5..d3c3ff062 100644 --- a/LDMP/calculate_prod.py +++ b/LDMP/calculate_prod.py @@ -17,12 +17,14 @@ import qgis.gui from qgis.PyQt import QtCore, QtWidgets, uic -from te_schemas.algorithms import ExecutionScript +from te_schemas.algorithms import AlgorithmRunMode, ExecutionScript from te_schemas.productivity import ProductivityMode from . import calculate, conf from .jobs.manager import job_manager from .logger import log +from .tasks import create_task + DlgCalculateProdUi, _ = uic.loadUiType( str(Path(__file__).parent / "gui/DlgCalculateProd.ui") @@ -270,7 +272,12 @@ def btn_calculate(self): else: raise ValueError("Unknown prod_mode {prod_mode}") - resp = job_manager.submit_remote_job(payload, self.script.id) + resp = create_task( + job_manager, + payload, + self.script.id, + AlgorithmRunMode.REMOTE, + ) if resp: main_msg = "Submitted" diff --git a/LDMP/calculate_rest_biomass.py b/LDMP/calculate_rest_biomass.py index fad355768..88c42299e 100644 --- a/LDMP/calculate_rest_biomass.py +++ b/LDMP/calculate_rest_biomass.py @@ -17,11 +17,12 @@ import qgis.core import qgis.gui from qgis.PyQt import QtWidgets, uic -from te_schemas.algorithms import ExecutionScript +from te_schemas.algorithms import AlgorithmRunMode, ExecutionScript from . import calculate, data_io from .jobs.manager import job_manager from .localexecution import biomassrestoration +from .tasks import create_task DlgCalculateRestBiomassDataUi, _ = uic.loadUiType( str(Path(__file__).parent / "gui/DlgCalculateRestBiomassData.ui") @@ -79,7 +80,13 @@ def calculate_on_GEE(self): "task_notes": self.task_notes.toPlainText(), } - resp = job_manager.submit_remote_job(payload, self.script.id) + + resp = create_task( + job_manager, + payload, + self.script.id, + AlgorithmRunMode.REMOTE, + ) if resp: main_msg = "Submitted" description = "Restoration biomass change submitted to Trends.Earth server." diff --git a/LDMP/calculate_soc.py b/LDMP/calculate_soc.py index 7c6d9e81b..135da245f 100644 --- a/LDMP/calculate_soc.py +++ b/LDMP/calculate_soc.py @@ -23,6 +23,7 @@ from .jobs.manager import job_manager from .lc_setup import get_trans_matrix from .logger import log +from .tasks import create_task DlgCalculateSocUi, _ = uic.loadUiType( str(Path(__file__).parent / "gui/DlgCalculateSOC.ui") @@ -286,7 +287,12 @@ def calculate_on_GEE(self): "task_notes": self.options_tab.task_notes.toPlainText(), } - resp = job_manager.submit_remote_job(payload, self.script.id) + resp = create_task( + job_manager, + payload, + self.script.id, + AlgorithmRunMode.REMOTE, + ) if resp: main_msg = "Submitted" description = "Soil organic carbon task submitted to Trends.Earth server." diff --git a/LDMP/calculate_tc.py b/LDMP/calculate_tc.py index a859a06e4..1fb0aaf5b 100644 --- a/LDMP/calculate_tc.py +++ b/LDMP/calculate_tc.py @@ -20,13 +20,14 @@ import qgis.gui from osgeo import gdal, osr from qgis.PyQt import QtCore, QtWidgets, uic -from te_schemas.algorithms import ExecutionScript +from te_schemas.algorithms import AlgorithmRunMode, ExecutionScript from te_schemas.schemas import BandInfo from . import GetTempFilename, calculate, conf, data_io, worker from .jobs.manager import job_manager from .logger import log from .summary import calc_cell_area +from .tasks import create_task DlgCalculateTcDataUi, _ = uic.loadUiType( str(Path(__file__).parent / "gui/DlgCalculateTCData.ui") @@ -427,7 +428,14 @@ def calculate_on_GEE(self, method, biomass_data): "task_name": self.execution_name_le.text(), "task_notes": self.task_notes.toPlainText(), } - resp = job_manager.submit_remote_job(payload, self.script.id) + + resp = create_task( + job_manager, + payload, + self.script.id, + AlgorithmRunMode.REMOTE, + ) + if resp: main_msg = "Submitted" description = "Total carbon submitted to Trends.Earth server." diff --git a/LDMP/calculate_unccd.py b/LDMP/calculate_unccd.py index f4f396175..c913b6308 100644 --- a/LDMP/calculate_unccd.py +++ b/LDMP/calculate_unccd.py @@ -17,13 +17,14 @@ import qgis.gui from qgis.PyQt import QtCore, QtWidgets, uic -from te_schemas.algorithms import ExecutionScript +from te_schemas.algorithms import AlgorithmRunMode, ExecutionScript from . import conf from .calculate import DlgCalculateBase from .jobs.manager import job_manager from .localexecution import unccd from .logger import log +from .tasks import create_task DlgCalculateUNCCDUi, _ = uic.loadUiType( str(Path(__file__).parent / "gui/DlgCalculateUNCCD.ui") @@ -135,7 +136,12 @@ def btn_calculate(self): self.close() - resp = job_manager.submit_remote_job(payload, self.script.id) + resp = create_task( + job_manager, + payload, + self.script.id, + AlgorithmRunMode.REMOTE, + ) if resp: main_msg = "Submitted" diff --git a/LDMP/calculate_urban.py b/LDMP/calculate_urban.py index 9af0b065a..6dcf3cc20 100644 --- a/LDMP/calculate_urban.py +++ b/LDMP/calculate_urban.py @@ -17,11 +17,12 @@ import qgis.core import qgis.gui from qgis.PyQt import QtCore, QtWidgets, uic -from te_schemas.algorithms import ExecutionScript +from te_schemas.algorithms import AlgorithmRunMode, ExecutionScript from . import calculate, data_io from .jobs.manager import job_manager from .logger import log +from .task import create_task DlgCalculateUrbanDataUi, _ = uic.loadUiType( str(Path(__file__).parent / "gui/DlgCalculateUrbanData.ui") @@ -196,7 +197,12 @@ def calculate_on_GEE(self): "task_notes": self.options_tab.task_notes.toPlainText(), } - resp = job_manager.submit_remote_job(payload, self.script.id) + resp = create_task( + job_manager, + payload, + self.script.id, + AlgorithmRunMode.REMOTE, + ) if resp: main_msg = "Submitted" diff --git a/LDMP/download_data.py b/LDMP/download_data.py index ff409e081..62bbdb9c7 100644 --- a/LDMP/download_data.py +++ b/LDMP/download_data.py @@ -17,12 +17,13 @@ import qgis.gui from qgis.PyQt import QtCore, QtGui, QtWidgets, uic -from te_schemas.algorithms import ExecutionScript +from te_schemas.algorithms import AlgorithmRunMode, ExecutionScript from . import calculate, conf from .conf import Setting, settings_manager from .jobs.manager import job_manager from .logger import log +from .tasks import create_task DlgDownloadUi, _ = uic.loadUiType(str(Path(__file__).parent / "gui/DlgDownload.ui")) @@ -271,7 +272,15 @@ def btn_calculate(self): "task_notes": "", } - resp = job_manager.submit_remote_job(payload, self.script.id) + + + resp = create_task( + job_manager, + payload, + self.script.id, + AlgorithmRunMode.REMOTE, + ) + if resp: main_msg = "Success" description = "Download request submitted to Trends.Earth server." diff --git a/LDMP/jobs/models.py b/LDMP/jobs/models.py index 7c09d010a..d3a959e52 100644 --- a/LDMP/jobs/models.py +++ b/LDMP/jobs/models.py @@ -69,7 +69,7 @@ def set_script_name_version(self, data, **kwargs): log(f"Failed to get script by id for {script_id}") script = get_job_local_script(data["script_name"]) else: - log(f"Failed to get script by id for {script_id}") + log(f"Got script from id {script_id}") script = ExecutionScript( script_id, run_mode=AlgorithmRunMode.NOT_APPLICABLE ) diff --git a/LDMP/landpks.py b/LDMP/landpks.py index 61f0cc48b..0ab78c0c7 100644 --- a/LDMP/landpks.py +++ b/LDMP/landpks.py @@ -16,11 +16,12 @@ import qgis.gui from qgis.PyQt import QtCore, QtGui, QtWidgets, uic -from te_schemas.algorithms import ExecutionScript +from te_schemas.algorithms import AlgorithmRunMode, ExecutionScript from . import calculate, conf from .jobs.manager import job_manager from .logger import log +from .tasks import create_task DlgLandPKSDownloadUi, _ = uic.loadUiType( str(Path(__file__).parent / "gui/DlgLandPKSDownload.ui") @@ -270,7 +271,13 @@ def btn_calculate(self): "task_notes": self.options_tab.task_notes.toPlainText(), } - resp = job_manager.submit_remote_job(payload, self.script.id) + resp = create_task( + job_manager, + payload, + self.script.id, + AlgorithmRunMode.REMOTE, + ) + if resp: main_msg = "Success" description = "Download request submitted to LandPKS." diff --git a/LDMP/tasks.py b/LDMP/tasks.py new file mode 100644 index 000000000..0c74ad660 --- /dev/null +++ b/LDMP/tasks.py @@ -0,0 +1,46 @@ +from qgis.core import QgsApplication, QgsTask +from qgis.utils import iface + +from te_schemas.algorithms import AlgorithmRunMode + +def submit_job(job_manager, payload, script_id, job_type, task): + """Function that submits a job and runs in a task.""" + try: + if job_type == AlgorithmRunMode.REMOTE: + job = job_manager.submit_remote_job(payload, script_id) + elif job_type == AlgorithmRunMode.LOCAL: + job = job_manager.submit_local_job(payload, script_id, aoi) + + return job + except Exception as e: + return None + + +def create_task(job_manager, payload, script_id, job_type, task_finished=None, aoi=None): + # Create a task using fromFunction + if task_finished is None: + task_finished = on_task_finished + + task = QgsTask.fromFunction( + "Submit Job", + submit_job, + on_finished=task_finished, + job_manager=job_manager, + payload=payload, + script_id=script_id, + job_type=job_type, + aoi=aoi + ) + + QgsApplication.taskManager().addTask(task) + + return task + +def on_task_finished(exception, result=None): + if exception is None: + if result: + print(f"Task completed successfully, job: {result}") + else: + print("Task completed but no job returned.") + else: + print(f"Task failed: {exception}") diff --git a/LDMP/timeseries.py b/LDMP/timeseries.py index 8f3c704ac..4fa8a6b67 100644 --- a/LDMP/timeseries.py +++ b/LDMP/timeseries.py @@ -17,7 +17,7 @@ import qgis.gui from qgis.PyQt import QtWidgets, uic from qgis.PyQt.QtCore import QDate, Qt -from te_schemas.algorithms import ExecutionScript +from te_schemas.algorithms import AlgorithmRunMode, ExecutionScript from .calculate import ( DlgCalculateBase, @@ -26,6 +26,7 @@ from .jobs.manager import job_manager from .logger import log from .settings import AreaWidget, AreaWidgetSection +from .tasks import create_task Ui_DlgTimeseries, _ = uic.loadUiType( str(Path(__file__).parent / "gui/DlgTimeseries.ui") @@ -312,7 +313,12 @@ def btn_calculate(self): ][self.traj_indic.currentText()]["params"] ) - resp = job_manager.submit_remote_job(payload, self.script.id) + resp = create_task( + job_manager, + payload, + self.script.id, + AlgorithmRunMode.REMOTE, + ) self.reset_widgets() From 47940cd50287af08e7a033af4f3a435b3884c833 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 12 Sep 2024 10:01:08 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- LDMP/calculate_drought_vulnerability.py | 4 ++-- LDMP/calculate_lc.py | 8 ++++---- LDMP/calculate_ldn.py | 9 ++------- LDMP/calculate_prod.py | 1 - LDMP/calculate_rest_biomass.py | 5 ++--- LDMP/calculate_soc.py | 4 ++-- LDMP/calculate_tc.py | 4 ++-- LDMP/calculate_unccd.py | 4 ++-- LDMP/calculate_urban.py | 4 ++-- LDMP/download_data.py | 2 -- LDMP/tasks.py | 9 ++++++--- LDMP/timeseries.py | 4 ++-- gee/landpks/landpks_landtrend_plot.ipynb | 13 +++++++------ gee/landpks/landpks_test_api.ipynb | 4 ++-- 14 files changed, 35 insertions(+), 40 deletions(-) diff --git a/LDMP/calculate_drought_vulnerability.py b/LDMP/calculate_drought_vulnerability.py index 85f0104a4..12dab4e93 100644 --- a/LDMP/calculate_drought_vulnerability.py +++ b/LDMP/calculate_drought_vulnerability.py @@ -148,8 +148,8 @@ def btn_calculate(self): resp = create_task( job_manager, - payload, - self.script.id, + payload, + self.script.id, AlgorithmRunMode.REMOTE, ) diff --git a/LDMP/calculate_lc.py b/LDMP/calculate_lc.py index bb4391b36..5e2ba8422 100644 --- a/LDMP/calculate_lc.py +++ b/LDMP/calculate_lc.py @@ -10,6 +10,7 @@ email : trends.earth@conservation.org ***************************************************************************/ """ + import functools import json from pathlib import Path @@ -21,8 +22,8 @@ from te_schemas.land_cover import LCLegendNesting, LCTransitionDefinitionDeg from . import calculate, lc_setup -from .tasks import create_task from .jobs.manager import job_manager +from .tasks import create_task DlgCalculateLcUi, _ = uic.loadUiType( str(Path(__file__).parent / "gui/DlgCalculateLC.ui") @@ -104,7 +105,7 @@ def calculate_on_GEE(self): payload, self.script.id, AlgorithmRunMode.REMOTE, - self.job_submitted + self.job_submitted, ) def job_submitted(self, exception, result=None): @@ -221,6 +222,5 @@ def calculate_locally(self): job_params, self.LOCAL_SCRIPT_NAME, AlgorithmRunMode.LOCAL, - self.aoi + self.aoi, ) - diff --git a/LDMP/calculate_ldn.py b/LDMP/calculate_ldn.py index 78f75d4e8..812625bea 100644 --- a/LDMP/calculate_ldn.py +++ b/LDMP/calculate_ldn.py @@ -24,13 +24,12 @@ from te_schemas.land_cover import LCLegendNesting, LCTransitionDefinitionDeg from te_schemas.productivity import ProductivityMode - -from .tasks import create_task from . import conf, lc_setup from .calculate import DlgCalculateBase from .jobs.manager import job_manager from .localexecution import ldn from .logger import log +from .tasks import create_task DlgCalculateOneStepUi, _ = uic.loadUiType( str(Path(__file__).parent / "gui/DlgCalculateOneStep.ui") @@ -625,12 +624,8 @@ def btn_calculate(self): self.close() for payload in payloads: - resp = create_task( - job_manager, - payload, - self.script.id, - AlgorithmRunMode.REMOTE + job_manager, payload, self.script.id, AlgorithmRunMode.REMOTE ) if resp: diff --git a/LDMP/calculate_prod.py b/LDMP/calculate_prod.py index d3c3ff062..7821908e5 100644 --- a/LDMP/calculate_prod.py +++ b/LDMP/calculate_prod.py @@ -25,7 +25,6 @@ from .logger import log from .tasks import create_task - DlgCalculateProdUi, _ = uic.loadUiType( str(Path(__file__).parent / "gui/DlgCalculateProd.ui") ) diff --git a/LDMP/calculate_rest_biomass.py b/LDMP/calculate_rest_biomass.py index 88c42299e..82304a2cc 100644 --- a/LDMP/calculate_rest_biomass.py +++ b/LDMP/calculate_rest_biomass.py @@ -80,11 +80,10 @@ def calculate_on_GEE(self): "task_notes": self.task_notes.toPlainText(), } - resp = create_task( job_manager, - payload, - self.script.id, + payload, + self.script.id, AlgorithmRunMode.REMOTE, ) if resp: diff --git a/LDMP/calculate_soc.py b/LDMP/calculate_soc.py index 135da245f..5e9bff512 100644 --- a/LDMP/calculate_soc.py +++ b/LDMP/calculate_soc.py @@ -289,8 +289,8 @@ def calculate_on_GEE(self): resp = create_task( job_manager, - payload, - self.script.id, + payload, + self.script.id, AlgorithmRunMode.REMOTE, ) if resp: diff --git a/LDMP/calculate_tc.py b/LDMP/calculate_tc.py index 1fb0aaf5b..908a3506b 100644 --- a/LDMP/calculate_tc.py +++ b/LDMP/calculate_tc.py @@ -431,8 +431,8 @@ def calculate_on_GEE(self, method, biomass_data): resp = create_task( job_manager, - payload, - self.script.id, + payload, + self.script.id, AlgorithmRunMode.REMOTE, ) diff --git a/LDMP/calculate_unccd.py b/LDMP/calculate_unccd.py index c913b6308..3cf117cb7 100644 --- a/LDMP/calculate_unccd.py +++ b/LDMP/calculate_unccd.py @@ -138,8 +138,8 @@ def btn_calculate(self): resp = create_task( job_manager, - payload, - self.script.id, + payload, + self.script.id, AlgorithmRunMode.REMOTE, ) diff --git a/LDMP/calculate_urban.py b/LDMP/calculate_urban.py index 6dcf3cc20..a3a092e4c 100644 --- a/LDMP/calculate_urban.py +++ b/LDMP/calculate_urban.py @@ -199,8 +199,8 @@ def calculate_on_GEE(self): resp = create_task( job_manager, - payload, - self.script.id, + payload, + self.script.id, AlgorithmRunMode.REMOTE, ) diff --git a/LDMP/download_data.py b/LDMP/download_data.py index 62bbdb9c7..27c1ce99a 100644 --- a/LDMP/download_data.py +++ b/LDMP/download_data.py @@ -272,8 +272,6 @@ def btn_calculate(self): "task_notes": "", } - - resp = create_task( job_manager, payload, diff --git a/LDMP/tasks.py b/LDMP/tasks.py index 0c74ad660..62016167f 100644 --- a/LDMP/tasks.py +++ b/LDMP/tasks.py @@ -1,8 +1,8 @@ from qgis.core import QgsApplication, QgsTask from qgis.utils import iface - from te_schemas.algorithms import AlgorithmRunMode + def submit_job(job_manager, payload, script_id, job_type, task): """Function that submits a job and runs in a task.""" try: @@ -16,7 +16,9 @@ def submit_job(job_manager, payload, script_id, job_type, task): return None -def create_task(job_manager, payload, script_id, job_type, task_finished=None, aoi=None): +def create_task( + job_manager, payload, script_id, job_type, task_finished=None, aoi=None +): # Create a task using fromFunction if task_finished is None: task_finished = on_task_finished @@ -29,13 +31,14 @@ def create_task(job_manager, payload, script_id, job_type, task_finished=None, a payload=payload, script_id=script_id, job_type=job_type, - aoi=aoi + aoi=aoi, ) QgsApplication.taskManager().addTask(task) return task + def on_task_finished(exception, result=None): if exception is None: if result: diff --git a/LDMP/timeseries.py b/LDMP/timeseries.py index 4fa8a6b67..d358375f3 100644 --- a/LDMP/timeseries.py +++ b/LDMP/timeseries.py @@ -315,8 +315,8 @@ def btn_calculate(self): resp = create_task( job_manager, - payload, - self.script.id, + payload, + self.script.id, AlgorithmRunMode.REMOTE, ) diff --git a/gee/landpks/landpks_landtrend_plot.ipynb b/gee/landpks/landpks_landtrend_plot.ipynb index a5179bf97..8eadcc375 100644 --- a/gee/landpks/landpks_landtrend_plot.ipynb +++ b/gee/landpks/landpks_landtrend_plot.ipynb @@ -9,17 +9,18 @@ "import json\n", "\n", "import ee\n", - "\n", - "from PIL import Image\n", - "import numpy as np\n", - "import matplotlib.pyplot as plt\n", "import matplotlib.gridspec as gridspec\n", + "import matplotlib.pyplot as plt\n", + "import numpy as np\n", "import pandas as pd\n", + "from PIL import Image\n", "\n", - "EE_ACCOUNT = 'gef-ldmp-server@gef-ld-toolbox.iam.gserviceaccount.com'\n", + "EE_ACCOUNT = \"gef-ldmp-server@gef-ld-toolbox.iam.gserviceaccount.com\"\n", "\n", "# The private key associated with your service account in JSON format.\n", - "EE_PRIVATE_KEY_FILE = 'C:/Users/azvoleff/Code/LandDegradation/decisiontheater/te_key.json'\n", + "EE_PRIVATE_KEY_FILE = (\n", + " \"C:/Users/azvoleff/Code/LandDegradation/decisiontheater/te_key.json\"\n", + ")\n", "\n", "EE_CREDENTIALS = ee.ServiceAccountCredentials(EE_ACCOUNT, EE_PRIVATE_KEY_FILE)\n", "ee.Initialize(EE_CREDENTIALS)\n", diff --git a/gee/landpks/landpks_test_api.ipynb b/gee/landpks/landpks_test_api.ipynb index c26972283..d46df3351 100644 --- a/gee/landpks/landpks_test_api.ipynb +++ b/gee/landpks/landpks_test_api.ipynb @@ -28,11 +28,11 @@ ], "source": [ "import json\n", - "import requests\n", "import time\n", "from getpass import getpass\n", "\n", "import ipyplot\n", + "import requests\n", "from IPython.display import Image" ] }, @@ -66,7 +66,7 @@ ], "source": [ "api_url = \"https://api.trends.earth\"\n", - "#api_url = \"http://localhost:3000\"\n", + "# api_url = \"http://localhost:3000\"\n", "email, password = input(\"Email: \"), getpass(\"Password: \")\n", "creds = {\"email\": email, \"password\": password}\n", "auth_url = api_url + \"/auth\"\n",