Skip to content

Commit

Permalink
Move main.py into package and add vanity CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
cthoyt committed Jan 17, 2021
1 parent b9cb58c commit 23cf328
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 5 deletions.
8 changes: 4 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -199,12 +199,12 @@ There are a few ways to run ``omop2obo``. An example workflow is provided below.
|
*COMMAND LINE* ➞ `main.py <https://github.com/callahantiff/OMOP2OBO/blob/master/main.py>`_
*COMMAND LINE* ➞ after installing with pip, the `omop2obo` command is available directly in your shell.

.. code:: bash
python main.py --help
Usage: main.py [OPTIONS]
omop2obo --help
Usage: omop2obo [OPTIONS]
The OMOP2OBO package provides functionality to assist with mapping OMOP standard clinical terminology
concepts to OBO terms. Successfully running this program requires several input parameters, which are
Expand Down Expand Up @@ -246,7 +246,7 @@ If you follow the instructions for how to format clinical data (`here <https://g
.. code:: bash
python main.py --clinical_domain condition --onts hp --onts mondo --clinical_data resources/clinical_data/omop2obo_conditions_june2020.csv
$ omop2obo --clinical_domain condition --onts hp --onts mondo --clinical_data resources/clinical_data/omop2obo_conditions_june2020.csv
|
Expand Down
14 changes: 14 additions & 0 deletions omop2obo/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# -*- coding: utf-8 -*-

"""Entrypoint module, in case you use `python -m omop2obo`.
Why does this file exist, and why ``__main__``? For more info, read:
- https://www.python.org/dev/peps/pep-0338/
- https://docs.python.org/3/using/cmdline.html#cmdoption-m
"""

from .main import main

if __name__ == '__main__':
main()
13 changes: 12 additions & 1 deletion main.py → omop2obo/main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""Command line interface for :mod:`omop2obo`.
Why does this file exist, and why not put this in ``__main__``? You might be tempted to import things from ``__main__``
later, but that will cause problems--the code will get executed twice:
- When you run ``python3 -m omop2obo`` python will execute``__main__.py`` as a script.
That means there won't be any ``omop2obo.__main__`` in ``sys.modules``.
- When you import __main__ it will get executed again (as a module) because
there's no ``omop2obo.__main__`` in ``sys.modules``.
.. seealso:: https://click.palletsprojects.com/en/7.x/setuptools/#setuptools-integration
"""

# import needed libraries
import click
Expand Down
5 changes: 5 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,9 @@ def find_version(*file_paths):
'scikit-learn==0.23.2',
'tqdm==4.54.1'],
extras_require=extras,
entry_points={
"console_scripts": [
'omop2obo = omop2obo.main:main',
],
},
)

0 comments on commit 23cf328

Please sign in to comment.