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

Code refactor #106

Closed
wants to merge 5 commits into from
Closed

Code refactor #106

wants to merge 5 commits into from

Conversation

hrshdhgd
Copy link
Contributor

@hrshdhgd hrshdhgd commented Feb 2, 2024

  • Use kghub_downloader as a standard package for downloading resources

  • Run tox and correct all errors

    Currently tox yields the following errors:

  • Command: tox -e lint

kg_microbe/transform_utils/uniprot/uniprot.py:1:1: D100 Missing docstring in public module
kg_microbe/transform_utils/uniprot/uniprot.py:9:1: F403 `from numpy import *` used; unable to detect undefined names
kg_microbe/transform_utils/uniprot/uniprot.py:21:7: D101 Missing docstring in public class
kg_microbe/transform_utils/uniprot/uniprot.py:22:9: D107 Missing docstring in `__init__`
kg_microbe/transform_utils/uniprot/uniprot.py:29:9: D401 First line of docstring should be in imperative mood: "Loads Uniprot data from api, then downloads after running once."
kg_microbe/transform_utils/uniprot/uniprot.py:61:9: D102 Missing docstring in public method
kg_microbe/transform_utils/uniprot/uniprot.py:78:9: D102 Missing docstring in public method
kg_microbe/transform_utils/uniprot/uniprot.py:106:9: D102 Missing docstring in public method
kg_microbe/transform_utils/uniprot/uniprot.py:111:9: D102 Missing docstring in public method
kg_microbe/transform_utils/uniprot/uniprot.py:120:121: E501 Line too long (357 > 120)
kg_microbe/utils/download_utils.py:1:1: D100 Missing docstring in public module
kg_microbe/utils/download_utils.py:34:5: D417 Missing argument descriptions in the docstring for `download_from_yaml`: `ignore_cache`, `mirror`, `output_dir`, `snippet_only`, `tags`
kg_microbe/utils/download_utils.py:42:5: D400 First line should end with a period
kg_microbe/utils/download_utils.py:42:5: D415 First line should end with a period, question mark, or exclamation point
kg_microbe/utils/download_utils.py:58:36: S506 Probable use of unsafe loader `FullLoader` with `yaml.load`. Allows instantiation of arbitrary objects. Consider `yaml.safe_load`.
kg_microbe/utils/download_utils.py:128:31: S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected.
kg_microbe/utils/download_utils.py:130:34: S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected.
kg_microbe/utils/download_utils.py:164:5: D103 Missing docstring in public function
kg_microbe/utils/download_utils.py:206:5: D205 1 blank line required between summary line and description
kg_microbe/utils/download_utils.py:206:5: D400 First line should end with a period
kg_microbe/utils/download_utils.py:206:5: D415 First line should end with a period, question mark, or exclamation point
kg_microbe/utils/download_utils.py:206:5: D414 Section has no content ("Returns")
kg_microbe/utils/download_utils.py:249:5: D417 Missing argument descriptions in the docstring for `elastic_search_query`: `index`, `preserve_order`, `query`, `request_timeout`, `scroll`
kg_microbe/utils/download_utils.py:288:5: D400 First line should end with a period
kg_microbe/utils/download_utils.py:288:5: D401 First line of docstring should be in imperative mood: "Parses a URL for any environment variables enclosed in {curly braces}"
kg_microbe/utils/download_utils.py:288:5: D415 First line should end with a period, question mark, or exclamation point
kg_microbe/utils/download_utils.py:301:5: D103 Missing docstring in public function
kg_microbe/utils/download_utils.py:314:5: D103 Missing docstring in public function
kg_microbe/utils/download_utils.py:368:121: E501 Line too long (141 > 120)
kg_microbe/utils/download_utils.py:376:5: D103 Missing docstring in public function
kg_microbe/utils/download_utils.py:388:5: D103 Missing docstring in public function
kg_microbe/utils/download_utils.py:448:5: D103 Missing docstring in public function
kg_microbe/utils/download_utils.py:454:5: F841 Local variable `first_response` is assigned to but never used
kg_microbe/utils/download_utils.py:456:21: E712 Comparison to `True` should be `cond is True` or `if cond:`
kg_microbe/utils/download_utils.py:460:13: F841 Local variable `next_response` is assigned to but never used
kg_microbe/utils/download_utils.py:467:5: D103 Missing docstring in public function
kg_microbe/utils/download_utils.py:477:24: B905 `zip()` without an explicit `strict=` parameter
Found 37 errors.
  • tox -e docstr-coverage yields
kg-microbe/kg_microbe/transform_utils/uniprot/uniprot.py"
 - No module docstring
 - No docstring for `UniprotTransform`
 - No docstring for `UniprotTransform.__init__`
 - No docstring for `UniprotTransform.get_uniprot_values_from_file`
 - No docstring for `UniprotTransform.get_uniprot_values_organism`
 - No docstring for `UniprotTransform.parse_binding_site`
 - No docstring for `UniprotTransform.write_to_df`
 Needed: 9; Found: 2; Missing: 7; Coverage: 22.2%


kg_microbe/utils/download_utils.py"
 - No module docstring
 - No docstring for `mirror_to_bucket`
 - No docstring for `parse_ncbitaxon_json`
 - No docstring for `get_uniprot_values_organism`
 - No docstring for `write_to_empty_orgs`
 - No docstring for `check_for_file_existence_in_batch`
 - No docstring for `get_jobs`
 - No docstring for `parse_response`
 Needed: 12; Found: 4; Missing: 8; Coverage: 33.3%

Your code has docstrings in Google style but the rest of the project follows the reST style e.g.:

def download(*args, **kwargs) -> None:
    """
    Download from list of URLs (default: download.yaml) into data directory (default: data/raw).

    :param yaml_file: Specify the YAML file containing a list of datasets to download.
    :param output_dir: A string pointing to the directory to download data to.
    :param snippet_only: Download 5 kB of each uncompressed source, for testing and file checks.
    :param ignore_cache: If specified, will ignore existing files and download again.
    :return: None
    """

It would be nice to keep it uniform across the board.

@hrshdhgd hrshdhgd mentioned this pull request Feb 2, 2024
@hrshdhgd
Copy link
Contributor Author

hrshdhgd commented Feb 2, 2024

I've corrected the GitHub workflow to run tox. Once the workflows pass, we can merge this PR

@hrshdhgd
Copy link
Contributor Author

hrshdhgd commented Feb 6, 2024

Closing in favor of #107

@hrshdhgd hrshdhgd closed this Feb 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant