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

%magic can be after indent or tab #694

Closed
yasirroni opened this issue Dec 23, 2020 · 4 comments · Fixed by #717
Closed

%magic can be after indent or tab #694

yasirroni opened this issue Dec 23, 2020 · 4 comments · Fixed by #717
Milestone

Comments

@yasirroni
Copy link

yasirroni commented Dec 23, 2020

I have a code that I expect to work both in colab and jupyter, also in .py

FROM_GOOGLE_COLAB = True
PROJECT_FOLDER = '/content/drive/MyDrive/SOME_REPO_NAME'
if FROM_GOOGLE_COLAB:
    !pip install somepackages

    from google.colab import drive
    drive.mount('/content/drive')
    %cd $PROJECT_FOLDER

But, jupytext didn't translate %cd as magic if it's indented or some white space exists before it.

%cd
!pip install somepackages 

# become:
# %cd
# !pip install somepackages 


if True:
    %cd
    !pip install somepackages
    pass

# become:
if True:
    %cd # not works
    # !pip install somepackages 
    pass
@mwouts
Copy link
Owner

mwouts commented Dec 28, 2020

Hi @yasirroni , thank you for reporting this... I was not aware that one could use indented magic commands 😄
That should be pretty easy to fix, I'll have a look soon.

@mwouts
Copy link
Owner

mwouts commented Jan 14, 2021

Hi @yasirroni , I have added a fix for this, it's on master now.

You can give it a try with

BUILD_JUPYTERLAB_EXTENSION=1 pip install git+https://github.com/mwouts/jupytext.git
# jupyter labextension install [email protected]  # If you use Jupyter Lab 2.x

@yasirroni
Copy link
Author

@mwouts If I use pip and jupyter notebook, how to install or upgrade the new jupytext extension from the master branch?

I strongly suggest this as a new issue and add this method to the readme!

@mwouts
Copy link
Owner

mwouts commented Jan 18, 2021

Oh sure! Well the command above should work (but it requires nodejs). And the simpler form also works:

# Install Jupytext + the server extension + the notebook extension (but not the jupyter lab extension)
pip install git+https://github.com/mwouts/jupytext.git

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 a pull request may close this issue.

2 participants