Skip to content

Commit

Permalink
chore: repalce abc abstract by raise NotImplementedError in ImportMixin
Browse files Browse the repository at this point in the history
  • Loading branch information
edelclaux authored and bouttier committed Aug 14, 2024
1 parent eb43238 commit 22e3600
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 21 deletions.
3 changes: 1 addition & 2 deletions backend/geonature/core/gn_commons/models/abstract_mixin.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
from .base import TModules
import abc
import typing


class AbstractMixin(abc.ABC):
class AbstractMixin:
_module: TModules = None

def __init__(self, module: TModules) -> None:
Expand Down
3 changes: 1 addition & 2 deletions backend/geonature/core/gn_synthese/module.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
from geonature.core.gn_commons.models import TModules

from geonature.core.gn_synthese.imports import SyntheseImportMixin
from geonature.utils.metaclass_utils import metaclass_resolver


class SyntheseModule(metaclass_resolver(TModules, SyntheseImportMixin)):
class SyntheseModule(TModules, SyntheseImportMixin):
__mapper_args__ = {"polymorphic_identity": "synthese"}

def generate_input_url_for_dataset(self, dataset):
Expand Down
22 changes: 7 additions & 15 deletions backend/geonature/core/imports/import_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

from bokeh.embed.standalone import StandaloneEmbedJson

from abc import abstractmethod
import typing


Expand All @@ -19,37 +18,30 @@ class ImportInputUrl(typing.TypedDict):

class ImportMixin(AbstractMixin):
@staticmethod
@abstractmethod
def statistics_labels() -> typing.List[ImportStatisticsLabels]:
pass
raise NotImplementedError

# The output of this method is NEVER used
@staticmethod
@abstractmethod
def preprocess_transient_data(imprt: TImports, df) -> set:
return None
raise NotImplementedError

@staticmethod
@abstractmethod
def check_transient_data(task, logger, imprt: TImports) -> None:
pass
raise NotImplementedError

@staticmethod
@abstractmethod
def import_data_to_destination(imprt: TImports) -> None:
pass
raise NotImplementedError

@staticmethod
@abstractmethod
def remove_data_from_destination(imprt: TImports) -> None:
pass
raise NotImplementedError

@staticmethod
@abstractmethod
def report_plot(imprt: TImports) -> StandaloneEmbedJson:
pass
raise NotImplementedError

@staticmethod
@abstractmethod
def compute_bounding_box(imprt: TImports) -> None:
pass
raise NotImplementedError
3 changes: 1 addition & 2 deletions contrib/gn_module_occhab/backend/gn_module_occhab/module.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
from geonature.core.gn_commons.models import TModules
from geonature.utils.metaclass_utils import metaclass_resolver

from .imports import OcchabImportMixin


class OcchabModule(metaclass_resolver(TModules, OcchabImportMixin)):
class OcchabModule(TModules, OcchabImportMixin):
__mapper_args__ = {"polymorphic_identity": "occhab"}

def generate_input_url_for_dataset(self, dataset):
Expand Down

0 comments on commit 22e3600

Please sign in to comment.