-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Errors management Unique version management
- Loading branch information
Showing
8 changed files
with
68 additions
and
69 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
data: | ||
externals: ../data/externals | ||
raw: ../data/raw | ||
processed: ../data/processed | ||
final: ../data/final | ||
results: ../results | ||
|
||
|
||
reload: true | ||
extract: true | ||
save_to_disk: false |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,43 @@ | ||
import os | ||
from omegaconf import DictConfig, OmegaConf | ||
from hydra.core.hydra_config import HydraConfig | ||
from src.unit_proccessing import * | ||
import hydra | ||
#from memory_profiler import memory_usage | ||
# from memory_profiler import memory_usage | ||
import warnings | ||
warnings.simplefilter(action='ignore', category=Warning) | ||
|
||
|
||
def manage_relative_path(config, abosulute_path): | ||
for name, relative_path in config.data.items(): | ||
if relative_path.startswith('../'): | ||
config['data'][name] = os.path.join(abosulute_path, relative_path.replace('../', '')) | ||
return config | ||
|
||
|
||
def manage_survey_definition(config): | ||
if config['surveys'] != 'all' and type(config['surveys']) == str: | ||
config['surveys'] = [config['surveys']] | ||
if config['survey_version'] != 'all' and type(config['survey_version']) == str: | ||
config['survey_version'] = [config['survey_version']] | ||
return config | ||
warnings.simplefilter(action='ignore', category=Warning) | ||
|
||
|
||
def manage_export_path(config): | ||
def manage_path(config): | ||
if config['export_path'] is not None: | ||
config['data']['externals'] = os.path.dirname(config['export_path']) | ||
if os.path.isabs(config['export_path']) is False: | ||
root_path = HydraConfig.get().runtime.cwd | ||
config['export_path'] = os.path.join(root_path, config['export_path']) | ||
config['environment']['data']['externals'] = os.path.dirname(config['export_path']) | ||
config['surveys'] = [os.path.basename(config['export_path'])] | ||
if os.path.isabs(config['output_file']) is False: | ||
root_path = HydraConfig.get().runtime.cwd | ||
config['output_file'] = os.path.join(root_path, config['output_file']) | ||
return config | ||
|
||
|
||
@hydra.main(config_path='configuration', version_base='1.1', config_name='main.yaml') | ||
def unit_risk_score(config: DictConfig) -> None: | ||
#print(OmegaConf.to_yaml(config)) | ||
# print(OmegaConf.to_yaml(config)) | ||
print("*" * 12) | ||
config = manage_export_path(config) | ||
config = manage_relative_path(config, hydra.utils.get_original_cwd()) | ||
config = manage_survey_definition(config) | ||
features_class = UnitDataProcessing(config) | ||
df_item = features_class.df_item | ||
df_unit = features_class.df_unit | ||
features_class.make_global_score() | ||
features_class.save() | ||
config = manage_path(config) | ||
try: | ||
survey_class = UnitDataProcessing(config) | ||
df_item = survey_class.df_item | ||
df_unit = survey_class.df_unit | ||
survey_class.make_global_score() | ||
survey_class.save() | ||
except ValueError as e: | ||
print(f"An error occurred: {e}") | ||
|
||
|
||
if __name__ == "__main__": | ||
unit_risk_score() | ||
#mem_usage = memory_usage(unit_risk_score) | ||
#print(f"Memory usage (in MB): {max(mem_usage)}") | ||
# mem_usage = memory_usage(unit_risk_score) | ||
# print(f"Memory usage (in MB): {max(mem_usage)}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters