Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Sep 12, 2024
1 parent 852d1b8 commit 47940cd
Show file tree
Hide file tree
Showing 14 changed files with 35 additions and 40 deletions.
4 changes: 2 additions & 2 deletions LDMP/calculate_drought_vulnerability.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ def btn_calculate(self):

resp = create_task(
job_manager,
payload,
self.script.id,
payload,
self.script.id,
AlgorithmRunMode.REMOTE,
)

Expand Down
8 changes: 4 additions & 4 deletions LDMP/calculate_lc.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
email : [email protected]
***************************************************************************/
"""

import functools

Check failure on line 14 in LDMP/calculate_lc.py

View workflow job for this annotation

GitHub Actions / build

Ruff (F401)

LDMP/calculate_lc.py:14:8: F401 `functools` imported but unused

Check failure on line 14 in LDMP/calculate_lc.py

View workflow job for this annotation

GitHub Actions / build

Ruff (F401)

LDMP/calculate_lc.py:14:8: F401 `functools` imported but unused
import json
from pathlib import Path
Expand All @@ -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")
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -221,6 +222,5 @@ def calculate_locally(self):
job_params,
self.LOCAL_SCRIPT_NAME,
AlgorithmRunMode.LOCAL,
self.aoi
self.aoi,
)

9 changes: 2 additions & 7 deletions LDMP/calculate_ldn.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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:
Expand Down
1 change: 0 additions & 1 deletion LDMP/calculate_prod.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
from .logger import log
from .tasks import create_task


DlgCalculateProdUi, _ = uic.loadUiType(
str(Path(__file__).parent / "gui/DlgCalculateProd.ui")
)
Expand Down
5 changes: 2 additions & 3 deletions LDMP/calculate_rest_biomass.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions LDMP/calculate_soc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions LDMP/calculate_tc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)

Expand Down
4 changes: 2 additions & 2 deletions LDMP/calculate_unccd.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ def btn_calculate(self):

resp = create_task(
job_manager,
payload,
self.script.id,
payload,
self.script.id,
AlgorithmRunMode.REMOTE,
)

Expand Down
4 changes: 2 additions & 2 deletions LDMP/calculate_urban.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,8 @@ def calculate_on_GEE(self):

resp = create_task(
job_manager,
payload,
self.script.id,
payload,
self.script.id,
AlgorithmRunMode.REMOTE,
)

Expand Down
2 changes: 0 additions & 2 deletions LDMP/download_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,6 @@ def btn_calculate(self):
"task_notes": "",
}



resp = create_task(
job_manager,
payload,
Expand Down
9 changes: 6 additions & 3 deletions LDMP/tasks.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from qgis.core import QgsApplication, QgsTask
from qgis.utils import iface

Check failure on line 2 in LDMP/tasks.py

View workflow job for this annotation

GitHub Actions / build

Ruff (F401)

LDMP/tasks.py:2:24: F401 `qgis.utils.iface` imported but unused

Check failure on line 2 in LDMP/tasks.py

View workflow job for this annotation

GitHub Actions / build

Ruff (F401)

LDMP/tasks.py:2:24: F401 `qgis.utils.iface` imported but unused

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:
Expand All @@ -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
Expand All @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions LDMP/timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,8 @@ def btn_calculate(self):

resp = create_task(
job_manager,
payload,
self.script.id,
payload,
self.script.id,
AlgorithmRunMode.REMOTE,
)

Expand Down
13 changes: 7 additions & 6 deletions gee/landpks/landpks_landtrend_plot.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '[email protected]'\n",
"EE_ACCOUNT = \"[email protected]\"\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",
Expand Down
4 changes: 2 additions & 2 deletions gee/landpks/landpks_test_api.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
},
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit 47940cd

Please sign in to comment.