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

active-py does not clear paired notebook cell #477

Closed
ucohen opened this issue Apr 2, 2020 · 3 comments
Closed

active-py does not clear paired notebook cell #477

ucohen opened this issue Apr 2, 2020 · 3 comments
Milestone

Comments

@ucohen
Copy link

ucohen commented Apr 2, 2020

In paired py,ipynb configuration, a marked raw cell with an "active": "py" metadata or with an active-py tag does not exclude the cell from notebook.

steps to reproduce:

  1. save test.py
  2. open test.py as notebook
  3. cells with active/tags set to py as shown in jupyter despite its marking
  4. active="ipynb" works as intended (saving the notebook causes commenting)

file to reproduce:
test.py:

# %% active="py"
print('should only be displayed in py file')

# %% tags=["active-py"]
print('should only be displayed in py file')

# %% active="ipynb"
# print('only in jupyter')

ipynb file:

{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "active": "py"
   },
   "outputs": [],
   "source": [
    "print('should only be displayed in py file')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "tags": [
     "active-py"
    ]
   },
   "outputs": [],
   "source": [
    "print('should only be displayed in py file')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "active": "ipynb"
   },
   "outputs": [],
   "source": [
    "print('only in jupyter')"
   ]
  }
 ],
 "metadata": {
  "jupytext": {
   "cell_metadata_filter": "tags,active,-all",
   "notebook_metadata_filter": "-all",
   "text_representation": {
    "extension": ".py",
    "format_name": "percent"
   }
  },
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.6"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}

@mwouts mwouts added this to the 1.4.2 milestone Apr 3, 2020
@mwouts
Copy link
Owner

mwouts commented Apr 3, 2020

Thanks @ucohen for reporting this.

My expectation would have been that cell 1 and 2 become raw cells (an not code cells, as seems to be the case here) - I'll have a look.

@mwouts
Copy link
Owner

mwouts commented Apr 3, 2020

Indeed, the active/inactive cells were not working properly in the percent format in Jupytext 1.4.1. This should be fixed now on master, and will be included in 1.4.2. Thank you for spoting and reporting this!

@mwouts mwouts closed this as completed Apr 3, 2020
@mwouts
Copy link
Owner

mwouts commented Apr 5, 2020

Jupytext 1.4.2 is now available on pypi: pip install jupytext==1.4.2, and is expected to fix this issue. Please let me know if you find the opposite! Thanks.

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

No branches or pull requests

2 participants