Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Throw error when importing empty directory #97

Open
BenPortner opened this issue May 18, 2021 · 1 comment
Open

Throw error when importing empty directory #97

BenPortner opened this issue May 18, 2021 · 1 comment
Labels
enhancement New feature or request minor

Comments

@BenPortner
Copy link
Member

Brightway throws no error when trying to import an empty directory and applying strategies after. Although the output says that 0 datasets were extracted, this information is easy to miss in the lengthy output:

Code

path = "C:/Users/myuser/myemptyfolder"
importer = bw.SingleOutputEcospold2Importer(path, 'empty-db')
importer.apply_strategies()

Output

Extracting XML data from 0 datasets
Extracted 0 datasets in 4.81 seconds
Applying strategy: normalize_units
Applying strategy: update_ecoinvent_locations
Applying strategy: remove_zero_amount_coproducts
Applying strategy: remove_zero_amount_inputs_with_no_activity
Applying strategy: remove_unnamed_parameters
Applying strategy: es2_assign_only_product_with_amount_as_reference_product
Applying strategy: assign_single_product_as_activity
Applying strategy: create_composite_code
Applying strategy: drop_unspecified_subcategories
Applying strategy: fix_ecoinvent_flows_pre35
Applying strategy: drop_temporary_outdated_biosphere_flows
Applying strategy: link_biosphere_by_flow_uuid
Applying strategy: link_internal_technosphere_by_composite_code
Applying strategy: delete_exchanges_missing_activity
Applying strategy: delete_ghost_exchanges
Applying strategy: remove_uncertainty_from_negative_loss_exchanges
Applying strategy: fix_unreasonably_high_lognormal_uncertainties
Applying strategy: set_lognormal_loc_value
Applying strategy: convert_activity_parameters_to_list
Applying strategy: add_cpc_classification_from_single_reference_product
Applied 20 strategies in 0.00 seconds

Proposal

Instead of going on business-as-usual, the importer should first check if the directory contains a .7z file. If yes, it should unpack it and check the extracted datasets-directory after. If the importer does not find a .7z file or the extracted directory does not include ecospold files, brightway should throw a descriptive error.

@BenPortner BenPortner added enhancement New feature or request minor labels May 18, 2021
@cmutel
Copy link
Member

cmutel commented Nov 1, 2021

@BenPortner Any interest in fixing this? I don't think 7z is supported in the stdlib, so we could just print an error, but the AB does it somehow...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request minor
Projects
None yet
Development

No branches or pull requests

2 participants