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

filter: Reduce file size with filter_support/ #937

Closed

Conversation

victorlin
Copy link
Member

Description of proposed changes

Currently, filter.py at 1897 lines is large and can be difficult to work with. This PR introduces a filter_support/ directory similar to util_support/, to help reduce the size of the subcommand files.

Starting with these, up for discussion:

  • FilterException -> filter_support.exceptions.FilterException
  • filter_kwargs_to_str -> filter_support.output.filter_kwargs_to_str

Thinking about the future, this also allows easier sharing of functions/variables between internal engines (see #920 (comment)).

Related issue(s)

N/A

Testing

Doctests updated accordingly.

@codecov
Copy link

codecov bot commented May 18, 2022

Codecov Report

Merging #937 (0613b21) into master (5916362) will increase coverage by 0.01%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master     #937      +/-   ##
==========================================
+ Coverage   59.34%   59.35%   +0.01%     
==========================================
  Files          42       44       +2     
  Lines        6011     6013       +2     
  Branches     1539     1539              
==========================================
+ Hits         3567     3569       +2     
  Misses       2185     2185              
  Partials      259      259              
Impacted Files Coverage Δ
augur/filter.py 96.13% <100.00%> (-0.11%) ⬇️
augur/filter_support/exceptions.py 100.00% <100.00%> (ø)
augur/filter_support/output.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5916362...0613b21. Read the comment docs.

@victorlin victorlin force-pushed the filter/add-filter-support branch 2 times, most recently from 7a5ef79 to 8313fe7 Compare May 24, 2022 21:10
@victorlin
Copy link
Member Author

Looking back at this, using filter_support/ seems to go backwards on #949 which replaced io.py+io_support/ with modular files under io/. I like that direction, but ran into some troubles replacing filter.py + filter_support/ with filter/. This is because io.py does not represent a subcommand while filter.py does, and subcommands currently require a top-level module (file) to be exposed:

augur/augur/__init__.py

Lines 134 to 145 in 0d06558

def command_name(command):
"""
Returns a short name for a command module.
"""
def remove_prefix(prefix, string):
return re.sub('^' + re.escape(prefix), '', string)
package = command.__package__
module_name = command.__name__
return remove_prefix(package, module_name).lstrip(".").replace("_", "-")

@victorlin
Copy link
Member Author

#997 is an alternative to this PR.

@victorlin
Copy link
Member Author

Closing in favor of #997.

@victorlin victorlin closed this Sep 29, 2022
@victorlin victorlin deleted the filter/add-filter-support branch September 29, 2022 21:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

1 participant