Skip to content

Commit

Permalink
Updates for latest marshmallow-dataclass version
Browse files Browse the repository at this point in the history
  • Loading branch information
azvoleff committed Nov 11, 2022
1 parent e3a8747 commit f14b995
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 26 deletions.
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ repos:
rev: v3.9.0
hooks:
- id: reorder-python-imports
- repo: https://github.com/asottile/pyupgrade
rev: v3.2.0
hooks:
- id: pyupgrade
#- repo: https://github.com/asottile/pyupgrade
# rev: v3.2.0
# hooks:
# - id: pyupgrade
# - repo: https://github.com/jackdewinter/pymarkdown
# rev: v0.9.8
# hooks:
Expand Down
24 changes: 13 additions & 11 deletions LDMP/jobs/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -560,10 +560,11 @@ def download_job_results(self, job: Job) -> Job:

if handler:
handler: typing.Callable
output_path = handler(job)
output_uri = handler(job)

if output_path is not None:
job.results.uri = output_path
if output_uri is not None:
job.results.uri = output_uri
log(f"job.results.uri is {job.results.uri}")
self._change_job_status(
job, jobs.JobStatus.DOWNLOADED, force_rewrite=True
)
Expand Down Expand Up @@ -669,7 +670,7 @@ def create_job_from_dataset(
now = dt.datetime.now(tz=dt.timezone.utc)
rasters = {
DataType.INT16.value: Raster(
uri=URI(uri=dataset_path, type="local"),
uri=URI(uri=dataset_path),
bands=[band_info],
datatype=DataType.INT16,
filetype=RasterFileType.GEOTIFF,
Expand All @@ -686,7 +687,7 @@ def create_job_from_dataset(
results=RasterResults(
name=f"{band_name} results",
rasters=rasters,
uri=URI(uri=dataset_path, type="local"),
uri=URI(uri=dataset_path),
),
task_name=tr_manager.tr("Imported dataset"),
task_notes="",
Expand Down Expand Up @@ -746,11 +747,11 @@ def _init_error_recode_layer(self, job: Job):
os.path.pardir,
"data",
"error_recode",
"error_recode_en.gpkg".format(locale),
"error_recode_en.gpkg",
),
output_path,
)
job.results.vector.uri = URI(uri=output_path, type="local")
job.results.vector.uri = URI(uri=output_path)

def _update_known_jobs_with_newly_submitted_job(self, job: Job):
status = job.status
Expand Down Expand Up @@ -798,7 +799,7 @@ def _download_cloud_results(self, job: jobs.Job) -> typing.Optional[Path]:
)
if not result:
return None
tile_uris.append(results.URI(uri=out_file, type="local"))
tile_uris.append(results.URI(uri=out_file))

raster.tile_uris = tile_uris

Expand All @@ -812,7 +813,7 @@ def _download_cloud_results(self, job: jobs.Job) -> typing.Optional[Path]:
bands=raster.bands,
datatype=raster.datatype,
filetype=raster.filetype,
uri=results.URI(uri=vrt_file, type="local"),
uri=results.URI(uri=vrt_file),
type=results.RasterType.TILED_RASTER,
)
else:
Expand All @@ -823,7 +824,7 @@ def _download_cloud_results(self, job: jobs.Job) -> typing.Optional[Path]:
)
if not result:
return None
raster_uri = results.URI(uri=out_file, type="local")
raster_uri = results.URI(uri=out_file)
raster.uri = raster_uri
out_rasters[key] = results.Raster(
uri=raster_uri,
Expand All @@ -846,12 +847,13 @@ def _download_cloud_results(self, job: jobs.Job) -> typing.Optional[Path]:
vrt_file = base_output_path.parent / f"{base_output_path.name}.vrt"
main_raster_file_paths = [raster.uri.uri for raster in out_rasters.values()]
combine_all_bands_into_vrt(main_raster_file_paths, vrt_file)
job.results.uri = results.URI(uri=vrt_file, type="local")
job.results.uri = results.URI(uri=vrt_file)
else:
job.results.uri = [*job.results.rasters.values()][0].uri

_set_results_extents_raster(job)

log(f"job.results.uri in download function is {job.results.uri!r}")
return job.results.uri

def _download_timeseries_table(self, job: Job) -> typing.Optional[Path]:
Expand Down
4 changes: 2 additions & 2 deletions LDMP/localexecution/biomassrestoration.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,10 @@ def compute_biomass_restoration(

biomass_job.results = RasterResults(
name="biomass_restoration_summary",
uri=URI(uri=output_path, type="local"),
uri=URI(uri=output_path),
rasters={
DataType.INT16.value: Raster(
uri=URI(uri=output_path, type="local"),
uri=URI(uri=output_path),
bands=output_bands,
datatype=DataType.INT16,
filetype=RasterFileType.GEOTIFF,
Expand Down
4 changes: 2 additions & 2 deletions LDMP/localexecution/landcover.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,10 @@ def compute_land_cover(
]
lc_job.results = RasterResults(
name="land_cover",
uri=URI(uri=dataset_output_path, type="local"),
uri=URI(uri=dataset_output_path),
rasters={
DataType.INT16.value: Raster(
uri=URI(uri=dataset_output_path, type="local"),
uri=URI(uri=dataset_output_path),
bands=bands,
datatype=DataType.INT16,
filetype=RasterFileType.GEOTIFF,
Expand Down
4 changes: 2 additions & 2 deletions LDMP/localexecution/soilorganiccarbon.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,10 @@ def compute_soil_organic_carbon(

soc_job.results = RasterResults(
name="soil_organic_carbon",
uri=URI(uri=dataset_output_path, type="local"),
uri=URI(uri=dataset_output_path),
rasters={
DataType.INT16.value: Raster(
uri=URI(uri=dataset_output_path, type="local"),
uri=URI(uri=dataset_output_path),
bands=bands,
datatype=DataType.INT16,
filetype=RasterFileType.GEOTIFF,
Expand Down
2 changes: 1 addition & 1 deletion LDMP/localexecution/totalcarbon.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def compute_total_carbon_summary_table(

tc_job.results = FileResults(
name="total_carbon_summary",
uri=URI(uri=summary_table_output_path, type="local"),
uri=URI(uri=summary_table_output_path),
)
tc_job.end_date = dt.datetime.now(dt.timezone.utc)
tc_job.progress = 100
Expand Down
2 changes: 1 addition & 1 deletion LDMP/localexecution/unccd.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,5 +208,5 @@ def compute_unccd_report(

return FileResults(
name="unccd_report",
uri=URI(uri=tar_gz_path, type="local"),
uri=URI(uri=tar_gz_path),
)
4 changes: 2 additions & 2 deletions LDMP/localexecution/urbanchange.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,10 @@ def compute_urban_change_summary_table(

urban_change_job.results = RasterResults(
name="urban_change_summary",
uri=URI(uri=output_path, type="local"),
uri=URI(uri=output_path),
rasters={
DataType.INT16.value: Raster(
uri=URI(uri=output_path, type="local"),
uri=URI(uri=output_path),
bands=bands,
datatype=DataType.INT16,
filetype=RasterFileType.GEOTIFF,
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ requests>=2.28.0
pyqtgraph>=0.12.4
openpyxl>=3.0.10
marshmallow>=3.18.0
marshmallow_dataclass[enum, union]==8.5.9
marshmallow_dataclass[enum, union]==8.5.10
git+https://github.com/ConservationInternational/trends.earth-schemas.git@develop
git+https://github.com/ConservationInternational/trends.earth-algorithms.git@develop

Expand Down

0 comments on commit f14b995

Please sign in to comment.