Skip to content

Commit

Permalink
feat: make get_bbox_computation_infos optional. No infos, no bbox.
Browse files Browse the repository at this point in the history
  • Loading branch information
edelclaux committed May 3, 2024
1 parent 8a9e6d4 commit 9a46c90
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 13 deletions.
1 change: 0 additions & 1 deletion backend/geonature/core/gn_synthese/imports/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,6 @@ def get_bbox_computation_infos():
A dictionary indexed by the keys from bbox.Key enum
"""
return {
bbox.Key.IS_RELEVANT: True,
bbox.Key.NAME_FIELD: "the_geom_4326",
bbox.Key.CODE_ENTITY: "observation",
}
Expand Down
13 changes: 2 additions & 11 deletions backend/geonature/core/imports/bbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
class Key(str, Enum):
CODE_ENTITY = "code_entity"
NAME_FIELD = "field_name"
IS_RELEVANT = "is_relevant"


def get_valid_bbox(imprt):
Expand All @@ -30,18 +29,10 @@ def get_valid_bbox(imprt):
"""
# Retrieve the name of the field and the name of the entity to retrieve geometries from
if "get_bbox_computation_infos" not in imprt.destination.module._imports_:
raise NotImplementedError(
f"function get_valid_bbox not implemented for an import with destination '{imprt.destination.code}, needs `get_bbox_computation_infos` function"
)
infos = imprt.destination.module._imports_["get_bbox_computation_infos"]()

if not Key.IS_RELEVANT in infos:
raise NotImplementedError(
f"The function get_valid_bbox implementation for an import with destination '{imprt.destination.code}' is incomplete. It requires '{Key.IS_RELEVANT}' field"
)
if not infos[Key.IS_RELEVANT]:
return None

infos = imprt.destination.module._imports_["get_bbox_computation_infos"]()

if not Key.CODE_ENTITY in infos:
raise NotImplementedError(
f"The function get_valid_bbox implementation for an import with destination '{imprt.destination.code}' is incomplete. It requires '{Key.CODE_ENTITY}' field"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,6 @@ def get_bbox_computation_infos():
A dictionary indexed by the keys from bbox.Key enum
"""
return {
bbox.Key.IS_RELEVANT: True,
bbox.Key.NAME_FIELD: "geom_4326",
bbox.Key.CODE_ENTITY: "station",
}
Expand Down

0 comments on commit 9a46c90

Please sign in to comment.