Skip to content

Commit

Permalink
Offline mode (#77)
Browse files Browse the repository at this point in the history
* Implement the offline mode
* Import jquery from code.jquery.com and dt from cdn.datatables.net
* Update documentation and move the changelog there

Co-authored-by: François Wouts <[email protected]>
  • Loading branch information
mwouts and fwouts authored Jun 22, 2022
1 parent 2862a8b commit cc816e9
Show file tree
Hide file tree
Showing 22 changed files with 435 additions and 229 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,10 @@ jobs:
flake8 itables tests
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --statistics
- name: Install a development version of 'itables'
run: pip install -e .
- name: Install a Jupyter Kernel
run: python -m ipykernel install --name itables-dev --user
run: python -m ipykernel install --name itables --user
- name: Test with pytest
run: pytest --cov=./ --cov-report=xml
- name: Upload coverage
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ dist

# Jupyter Book
_build

# External dependencies
itables/external
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ exclude: >
repos:

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0
rev: v4.3.0
hooks:
- id: check-json
- id: check-yaml
Expand All @@ -34,7 +34,7 @@ repos:
- id: black

- repo: https://github.com/asottile/pyupgrade
rev: v2.31.1
rev: v2.34.0
hooks:
- id: pyupgrade
args: ["--py36-plus"]
147 changes: 0 additions & 147 deletions CHANGELOG.md

This file was deleted.

17 changes: 14 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ init_notebook_mode(all_interactive=True)
```
or use `itables.show` to show just one Series or DataFrame as an interactive table.

(NB: In Jupyter Notebook, Jupyter NBconvert and Jupyter Book, you need to call `init_notebook_mode()` before using `show`).
Since `itables==1.0.0`, the [jquery](https://jquery.com/) and [datatables.net](https://datatables.net/) libraries and CSS
are injected in the notebook when you execute `init_notebook_mode` with its default argument `connected=False`.
Thanks to this the interactive tables will work even without a connection to the internet.

If you prefer to load the libraries dynamically (and keep the notebook lighter), use `connected=True` when you
execute `init_notebook_mode`.

## Documentation

Expand All @@ -47,9 +52,15 @@ You can run our examples notebooks directly on [![Lab](https://img.shields.io/ba

If the table just says "Loading...", then maybe
- You loaded a notebook that is not trusted (run "Trust Notebook" in View / Activate Command Palette)
- Or you are offline?
- You forgot to run `init_notebook_mode`, or you deleted that cell or its output
- Or you ran `init_notebook_mode(connected=True)` but you are not connected to the internet?

Please note that if you change the value of the `connected` argument in
the `init_notebook_mode` cell, you will need to re-execute all the cells
that display interactive tables.

At the moment `itables` does not have an [offline mode](https://github.com/mwouts/itables/issues/8). While the table data is embedded in the notebook, the `jquery` and `datatables.net` are loaded from a CDN, see our [require.config](https://github.com/mwouts/itables/blob/main/itables/javascript/load_datatables_connected.js) and our [table template](https://github.com/mwouts/itables/blob/main/itables/datatables_template.html), so an internet connection is required to display the tables.
If the above does not help, please check out the [ChangeLog](docs/changelog.md)
and decide whether you should upgrade `itables`.

## <a name="downsampling"></a> Downsampling

Expand Down
1 change: 1 addition & 0 deletions docs/_toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ chapters:
- file: references
- file: developing
- file: troubleshooting
- file: changelog
143 changes: 143 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
ITables ChangeLog
=================

1.0.0 (2022-06-22)
------------------

**Added**
- ITables works offline! ([#8](https://github.com/mwouts/jupytext/issues/8), [#70](https://github.com/mwouts/jupytext/issues/70)). Marc would like to thank
[Allan Jardine](https://sprymedia.co.uk/), the author of the [datatables](https://datatables.net/) library,
and [François Wouts](https://github.com/fwouts) for their precious help on the subject.


**Changed**
- ITables uses the ESM version 1.12.1 of datatables.net


0.4.7 (2022-04-13)
------------------

**Added**
- Additional `tags` like e.g. captions are supported ([#10](https://github.com/mwouts/jupytext/issues/10)).


0.4.6 (2022-03-29)
------------------

**Changed**
- We have removed the default column width at 70 pixels ([#61](https://github.com/mwouts/jupytext/issues/61), [#62](https://github.com/mwouts/jupytext/issues/62), [#66](https://github.com/mwouts/jupytext/issues/66))
- We now use `pyupgrade` in our pre-commit hooks

**Fixed**
- We have improved the rendering of multiindex columns ([#63](https://github.com/mwouts/jupytext/issues/63))


0.4.5 (2022-01-25)
------------------

**Changed**
- The `itables` documentation now uses Jupyter Book ([#56](https://github.com/mwouts/jupytext/issues/56))
- We have added a new `style` option in `itables.options` and in `show`, with a default value equal to `max-width:100%`.


0.4.4 (2022-01-10)
------------------

**Fixed**
- Add 'require_config.js' to the pip package ([#48](https://github.com/mwouts/jupytext/issues/48))


0.4.3 (2022-01-08)
------------------

**Changed**
- When a JS function is created on the Python side, we export it as-is (without quotes) in the HTML file and don't use JS eval anymore.


0.4.2 (2022-01-07)
------------------

**Fixed**
- Fix the HTML output when `eval_functions=True`
- Display "Loading..." under the table header until the table is displayed with datatables.net
- `init_notebook_mode(all_interactive=False)` restores the original Pandas HTML representation.

0.4.1 (2022-01-06)
------------------

**Fixed**
- Long column names don't overlap anymore ([#28](https://github.com/mwouts/jupytext/issues/28))


0.4.0 (2022-01-06)
------------------

r**Fixed**
- Now `itables` also works in Jupyter Lab, Colab, VS Code and PyCharm ([#3](https://github.com/mwouts/jupytext/issues/3), [#4](https://github.com/mwouts/jupytext/issues/4), [#26](https://github.com/mwouts/jupytext/issues/26), [#40](https://github.com/mwouts/jupytext/issues/40)), as we load the `datatables.net` library with an ES import when `require.js` is not available. Many thanks to [François Wouts](https://github.com/fwouts) for his precious help!

**Changed**
- The `show` function (and `itables.options`) has a new argument `eval_functions`. When set to `True`, the nested strings passed to `datatables.net` that start with `function` are converted to Javascript functions.
- The HTML code for the datatables.net representation of the table is generated with an HTML template.
- We use f-strings and thus require Python >= 3.6


0.3.1 (2021-12-24)
------------------

**Fixed**
- We fixed an issue (`jquery` not found) with the HTML export when using `nbconvert>=6.0` ([#21](https://github.com/mwouts/jupytext/issues/21))
- We documented how to change the default ordering of rows - with the `order` option ([#30](https://github.com/mwouts/jupytext/issues/30))
- We documented how to load `require` in Jupyter Lab ([#3](https://github.com/mwouts/jupytext/issues/3))

**Changed**
- The main branch for the project is `main` rather than `master`
- Updated `datatables` to 1.11.3 and `jquery` to 3.5.1


0.3.0 (2020-12-14)
------------------

**Fixed**
- `itables` now has an explicit `init_notebook_mode` function, which inserts the datatables.net library in the notebook. Use `init_notebook_mode(all_interactive=True)` to display all the pandas object as interactive tables. This fixes ([#6](https://github.com/mwouts/jupytext/issues/6)) and ([#17](https://github.com/mwouts/jupytext/issues/17)).

**Changed**
- `itables` uses GitHub Actions for the CI.

**Added**
- `itables` is tested with Python 3.9 as well.


0.2.2 (2020-10-01)
------------------

**Fixed**
- Pandas' `display.max_columns` can be `None`, by Arthur Deygin ([#14](https://github.com/mwouts/jupytext/issues/14))


0.2.1 (2019-11-21)
------------------

**Added**
- Animated screenshot in README

**Fixed**
- Add IPython to setup.py install_requires, by Jon Shao ([#9](https://github.com/mwouts/jupytext/issues/9))


0.2.0 (2019-11-20)
------------------

**Added**
- Large tables are downsampled ([#2](https://github.com/mwouts/jupytext/issues/2))

**Changed**
- Javascript code moved to Javascript files

**Fixed**
- Tables with many columns are now well rendered ([#5](https://github.com/mwouts/jupytext/issues/5))


0.1.0 (2019-04-23)
------------------

Initial release
8 changes: 6 additions & 2 deletions docs/developing.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ mamba env update --file environment.yml

Then, activate that environment with
```shell
conda activate itables-dev
conda activate itables
```

Install the pre-commit hooks with
Expand All @@ -35,7 +35,11 @@ pytest

The `itables` documentation uses [Jupyter Book](https://jupyterbook.org/).

To build the documentation locally, use
To build the documentation locally, create a kernel named `itables` with
```shell
python -m ipykernel install --name itables --user
```
and then build the documentation with
```
jupyter-book build docs
```
Expand Down
Loading

0 comments on commit cc816e9

Please sign in to comment.