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

Remove more unused imports #995

Merged
merged 25 commits into from
May 12, 2023
Merged

Remove more unused imports #995

merged 25 commits into from
May 12, 2023

Conversation

wigging
Copy link
Contributor

@wigging wigging commented Mar 31, 2023

Fixes/Resolves:

Resolves issue #994.

Summary/Motivation:

Remove unused imports throughout the watertap package. After this pull request is merged, the GitHub Actions should be updated to check future pull requests for unused imports.

Changes proposed in this PR:

  • Remove unused imports

Legal Acknowledgement

By contributing to this software project, I agree to the following terms and conditions for my contribution:

  1. I agree my contributions are submitted under the license terms described in the LICENSE.txt file at the top level of this directory.
  2. I represent I am authorized to make the contributions and grant the license. If my employer has rights to intellectual property that includes these contributions, I represent that I have received permission to make contributions and grant the required license on behalf of that employer.

@wigging
Copy link
Contributor Author

wigging commented Mar 31, 2023

The CONFIG_Template that is imported in watertap/core/membrane_channel0d.py is unused in that file. However, if CONFIG_Template is removed then it breaks everything in watertap. It appears to be imported in the membrane_channel0d.py and then imported from that file into other files. CONFIG_Template is created in the membrane_channel_base.py so why isn't it imported from that file throughout the package?

@codecov
Copy link

codecov bot commented Mar 31, 2023

Codecov Report

Merging #995 (0dd21fc) into main (1334584) will decrease coverage by 0.01%.
The diff coverage is 100.00%.

❗ Current head 0dd21fc differs from pull request most recent head 54b7cde. Consider uploading reports for the commit 54b7cde to get more accurate results

@@            Coverage Diff             @@
##             main     #995      +/-   ##
==========================================
- Coverage   95.83%   95.82%   -0.01%     
==========================================
  Files         301      301              
  Lines       28801    28767      -34     
==========================================
- Hits        27601    27567      -34     
  Misses       1200     1200              
Impacted Files Coverage Δ
..._anaerobic_digester/GLSD_anaerobic_digestion_ui.py 100.00% <ø> (ø)
...tewater_resource_recovery/amo_1575_hrcs/hrcs_ui.py 100.00% <ø> (ø)
...r_resource_recovery/amo_1575_magprex/magprex_ui.py 100.00% <ø> (ø)
...o_1595_photothermal_membrane_candoP/amo_1595_ui.py 100.00% <ø> (ø)
...stewater_resource_recovery/amo_1690/amo_1690_ui.py 100.00% <ø> (ø)
...iomembrane_filtration/biomembrane_filtration_ui.py 100.00% <ø> (ø)
...e_recovery/dye_desalination/dye_desalination_ui.py 100.00% <ø> (ø)
...ent_removal/electrochemical_nutrient_removal_ui.py 100.00% <ø> (ø)
.../groundwater_treatment/groundwater_treatment_ui.py 100.00% <ø> (ø)
...ies/wastewater_resource_recovery/metab/metab_ui.py 100.00% <ø> (ø)
... and 30 more

@wigging
Copy link
Contributor Author

wigging commented Apr 4, 2023

The ConcentrationPolarizationType that is imported in watertap/unit_models/reverse_osmosis_0D.py is not used in that file. However, ConcentrationPolarizationType is imported from watertap/unit_models/reverse_osmosis_0D.py by other files. Why is this not imported from watertap/core/membrane_channel_base.py where it is originally defined?

@adam-a-a adam-a-a added the software admin Issues related to requirements, releases, etc. label Apr 6, 2023
@lbianchi-lbl lbianchi-lbl added the Priority:Normal Normal Priority Issue or PR label Apr 6, 2023
@adam-a-a
Copy link
Contributor

adam-a-a commented Apr 13, 2023

The ConcentrationPolarizationType that is imported in watertap/unit_models/reverse_osmosis_0D.py is not used in that file. However, ConcentrationPolarizationType is imported from watertap/unit_models/reverse_osmosis_0D.py by other files. Why is this not imported from watertap/core/membrane_channel_base.py where it is originally defined?

@wigging This was probably an oversight from when the RO 0D and 1D models were refactored with the new creation of the membrane_channel control volumes. I think you can alter the import to take straight from membrane_channel_base

@bknueven
Copy link
Contributor

The ConcentrationPolarizationType that is imported in watertap/unit_models/reverse_osmosis_0D.py is not used in that file. However, ConcentrationPolarizationType is imported from watertap/unit_models/reverse_osmosis_0D.py by other files. Why is this not imported from watertap/core/membrane_channel_base.py where it is originally defined?

@wigging This was probably an oversight from when the RO 0D and 1D models were refactored with the new creation of the membrane_channel control volumes. I think you can alter the import to take straight from membrane_channel_base

I would not be in favor of doing this -- I think the correct API has these things imported from the RO module. Users using the RO module don't need to know about watertap.core.membrane_channel_base.

@wigging
Copy link
Contributor Author

wigging commented Apr 13, 2023

@bknueven The ConcentrationPolarizationType is imported from watertap.core not from watertap.core.membrane_channel_base. It is defined in watertap.core.membrane_channel_base but it is imported from core because of how it's handled in __init__.py.

@adam-a-a
Copy link
Contributor

Hmmm.. I see @bknueven 's point though. So in that case, it wasn't an oversight. For the user's sake, it would make more sense for a user to import ConcentrationPolarizationType from the RO unit (or at least have the option to).

@bknueven
Copy link
Contributor

Hmmm.. I see @bknueven 's point though. So in that case, it wasn't an oversight. For the user's sake, it would make more sense for a user to import ConcentrationPolarizationType from the RO unit (or at least have the option to).

Yes, the current behavior is intentional.

All the "option types" for the RO unit should be imported from a single location, IMHO.

@wigging wigging force-pushed the unused-imports branch 2 times, most recently from a6b0709 to 29e849e Compare April 14, 2023 15:36
@wigging wigging marked this pull request as ready for review April 14, 2023 16:44
@wigging
Copy link
Contributor Author

wigging commented Apr 14, 2023

@bknueven The enums ConcentrationPolarizationType, MassTransferCoefficient, PressureChangeType, and FrictionFactor are setup in watertap so they can be imported from watertap.core. It looks like this follows the IDAES approach where things like MaterialBalanceType and FlowDirection are imported from idaes.core.

@bknueven
Copy link
Contributor

Let's do the following

  1. Move watertap/unit_models/reverse_osmosis_*.py to new directory watertap/unit_models/reverse_osmosis/
  2. Put the enums for reverse osmosis into watertap/unit_models/reverse_osmosis/__init__.py along side the unit model classes.

Then the API will be reasonably consistent between our various unit models. I would also be happy to leave the unused imports alone in these modules -- they do serve a specific purpose.

@wigging
Copy link
Contributor Author

wigging commented Apr 21, 2023

@bknueven I reverted the last two commits since the purpose of this pull request is to fix unused imports (not the API). To appease the linter and keep the original API, I added a few lines to the reverse osmosis unit models. See the latest commit. The use of the enum types and where they are located in the package should be handled better in watertap but I don't want to tackle that in this pull request.

Copy link
Contributor

@adam-a-a adam-a-a left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@wigging
Copy link
Contributor Author

wigging commented May 12, 2023

@lbianchi-lbl Is anything else needed for this pull request?

@lbianchi-lbl lbianchi-lbl linked an issue May 12, 2023 that may be closed by this pull request
@lbianchi-lbl
Copy link
Contributor

@lbianchi-lbl Is anything else needed for this pull request?

Nope, thanks for bringing this over the finish line!

@lbianchi-lbl lbianchi-lbl self-requested a review May 12, 2023 13:37
@lbianchi-lbl lbianchi-lbl enabled auto-merge (squash) May 12, 2023 13:37
@lbianchi-lbl lbianchi-lbl merged commit a607709 into main May 12, 2023
@lbianchi-lbl lbianchi-lbl deleted the unused-imports branch May 12, 2023 14:04
lbianchi-lbl added a commit to watertap-org/parameter-sweep that referenced this pull request May 1, 2024
* Remove unused imports from core subdirectories

* Remove unused imports from core

* Undo CONFIG_Template removal

* Remove unused imports from edb and property_models

* Remove unused imports in tools

* Remove unused imports in top-level of unit_models

* Re-add the ConcentrationPolarizationType

* Remove more unused imports in unit_models

* Fix CONFIG_Template imports

* Use Base_CONFIG_Template in membrane_channel0d

* Remove unused imports in tests for chemistry examples

* Remove unused imports in custom_model_demo examples

* Remove unused imports from edb examples

* Remove imports from flowsheets case_studies wastewater_resource_recovery examples

* Remove unused imports from wastewastewater_resource_recovery examples

* Remove some imports from electrodialysis examples

* Remove imports from ion_exchange examples

* Remove imports from oaro examples

* Remove imports from RO_with_energy_recovery examples

* Remove unused imports from full_treatment_train examples

* Define build_components as variable in flowsheet_two_stage

* Fix unused import warnings for ConcentrationPolarizationType and MassTransferCoefficient

* Add instruction to ignore unused import warning

* Enable unused-import Pylint check

* Remove some more unused imports

---------

Co-authored-by: Ludovico Bianchi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority:Normal Normal Priority Issue or PR software admin Issues related to requirements, releases, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove more unused imports
4 participants