Skip to content

Commit

Permalink
refactor(app) refactor descriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertoChiosa committed Apr 26, 2024
1 parent 9268e9e commit 151bd17
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions src/portable_app_framework/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def fetch(self) -> dict:
This method returns the mapping convention between the internal naming convention (i.e., naming convention
defined in the SPARQL query) an the external naming convention (i.e., naming convention used in the building)
:return:
:return dict: mapping between internal and external naming convention
"""
self.logger.debug(f'Fetching metadata based on sparql query')
# Perform query on rdf graph
Expand All @@ -137,9 +137,13 @@ def fetch(self) -> dict:
# return mapping
return int_to_ext

def remap(self, data: pd.DataFrame, fetch_map_dict: dict, mode=None):
def remap(self, data: pd.DataFrame, fetch_map_dict: dict, mode=None) -> pd.DataFrame:
"""
The internal_external_mapping component performs the actual mapping of the internal data to the external data
:param data: The dataframe to be mapped
:param fetch_map_dict: The mapping dictionary with key-value pairs
:param mode: The mode of the mapping (to_internal or to_external)
:return: The mapped dataframe
"""

dict_to_external = fetch_map_dict
Expand All @@ -159,9 +163,6 @@ def remap(self, data: pd.DataFrame, fetch_map_dict: dict, mode=None):
def clean(self, *args, **kwargs):
"""
The purpose of this component is to perform the actual analysis of the data.
The output of the "analyze" component is a set of timeseries dataframes
containing the results of the analysis. The application saves the data in the form of ApplicationData class.
"""
# Dynamically import the analyze module
clean_module = importlib.import_module(f"app.{self.app_name}.clean", package=__name__)
Expand All @@ -174,15 +175,12 @@ def clean(self, *args, **kwargs):
self.res_clean = clean_fn(*args, **kwargs)
return self.res_clean
else:
print(f"Function {clean_fn} not found in analyze module.")
self.logger.error(f"Function {clean_fn} not found in analyze module.")
return None

def analyze(self, *args, **kwargs):
"""
The purpose of this component is to perform the actual analysis of the data.
The output of the "analyze" component is a set of timeseries dataframes
containing the results of the analysis. The application saves the data in the form of ApplicationData class.
"""
# Dynamically import the analyze module
analyze_module = importlib.import_module(f"app.{self.app_name}.analyze", package=__name__)
Expand All @@ -195,7 +193,7 @@ def analyze(self, *args, **kwargs):
self.res_analyze = analyze_fn(*args, **kwargs)
return self.res_analyze
else:
print(f"Function {analyze_fn} not found in analyze module.")
self.logger.error(f"Function {analyze_fn} not found in analyze module.")
return None


Expand Down

0 comments on commit 151bd17

Please sign in to comment.