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

Add __main__ to allow calling via python -m #739

Merged
merged 2 commits into from
Feb 10, 2021

Conversation

matthew-brett
Copy link
Contributor

Allows e.g.

python -m jupytext my_notebook.ipynb --to Rmd

I think this is the correct way to do this, but I don't personally
have much experience with this machinery.

@mwouts
Copy link
Owner

mwouts commented Feb 10, 2021

Thank you @matthew-brett , yes sure that would be an interesting feature! Personally I sometimes call pip or ipykernel in this way, maybe I'll have a look at their implementation... Also sorry for the thresholds on coverage, I know they are set quite high, anyway in this case it should be easy to copy and adjust one of the tests in test_cli.py.

@mwouts mwouts added this to the 1.10.1 milestone Feb 10, 2021
@matthew-brett
Copy link
Contributor Author

Yes - I use pip that way often too - I basically copied / adapted what pip did, here.

I look into tests fairly soon.

Allows e.g.

```
python -m jupytext my_notebook.ipynb --to Rmd
```
@matthew-brett
Copy link
Contributor Author

Actually, looking into it, I don't think it will be trivial to get the test coverage up. The test_cli.py module tests the functions in the cli.py module, but the __main__.py here will only run as __main__ - i.e. when the file gets invoked as a script. I think that will have to be tested as a subprocess - but I don't think that will register in the test coverage.

@matthew-brett matthew-brett force-pushed the add-m-module branch 2 times, most recently from 6d7578f to f4fe936 Compare February 10, 2021 10:13
Test invocation via `python -m jupytext`.
@matthew-brett
Copy link
Contributor Author

I stand corrected - it looks like the subprocess test did increase the coverage.

@mwouts mwouts merged commit 65436fb into mwouts:master Feb 10, 2021
@mwouts
Copy link
Owner

mwouts commented Feb 10, 2021

Thank you @matthew-brett for this! Yes indeed the calls through subprocess seem to count in the coverage... except when we're doing fancy things like calling jupytext through pre-commit hooks like in test_pre_commit_3_sync_black_nbstripout.py 😄

@matthew-brett matthew-brett deleted the add-m-module branch February 12, 2021 01:29
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.

2 participants