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

[docs] isolate import cells #653

Closed
jmoralez opened this issue Sep 28, 2023 · 2 comments · Fixed by #691
Closed

[docs] isolate import cells #653

jmoralez opened this issue Sep 28, 2023 · 2 comments · Fixed by #691

Comments

@jmoralez
Copy link
Member

Description

nbdev runs cells that contain import statements when building the docs, so when we have more code in there we incur in an unnecessary cost and it takes more time to build them, which can slow down development when previewing locally and also takes longer to deploy when pushing new commits.

We should isolate all cells that contain import statements to have only that, as is suggested here.

Warning
Do not mix import statements (or calls to show_doc) with other code in a single cell. If you do, all the code in that cell will be executed every time you build your docs, which might lead to errors (since not all previous cells will have been executed.
Instead, put your imports in separate cells, and calls to show_doc should contain only that one line of code – the show_doc call.

Link

No response

@jmoralez
Copy link
Member Author

jmoralez commented Sep 28, 2023

At the time of opening this issue these are the notebooks in main:

  • nbs/index.ipynb
  • nbs/src/adapters.prophet.ipynb
  • nbs/src/mstl.ipynb
  • nbs/src/distributed.utils.ipynb
  • nbs/src/theta.ipynb
  • nbs/src/utils.ipynb
  • nbs/src/garch.ipynb
  • nbs/src/ets.ipynb
  • nbs/src/core/models.ipynb
  • nbs/src/core/distributed.fugue.ipynb
  • nbs/src/core/core.ipynb
  • nbs/src/distributed.core.ipynb
  • nbs/src/ces.ipynb
  • nbs/src/arima.ipynb
  • nbs/src/distributed.multiprocess.ipynb
  • nbs/docs/how-to-guides/numba_cache.ipynb
  • nbs/docs/how-to-guides/ray.ipynb
  • nbs/docs/how-to-guides/AutoArima_vs_Prophet.ipynb
  • nbs/docs/how-to-guides/Prophet_spark_m5.ipynb
  • nbs/docs/how-to-guides/AmazonStatsForecast.ipynb
  • nbs/docs/how-to-guides/ETS_ray_m5.ipynb
  • nbs/docs/how-to-guides/spark.ipynb
  • nbs/docs/how-to-guides/Getting_Started_complete_polars.ipynb
  • nbs/docs/how-to-guides/dask.ipynb
  • nbs/docs/how-to-guides/00_Automatic_Forecasting.ipynb
  • nbs/docs/how-to-guides/Exogenous.ipynb
  • nbs/docs/getting-started/2_Getting_Started_complete.ipynb
  • nbs/docs/getting-started/0_Installation.ipynb
  • nbs/docs/getting-started/1_Getting_Started_short.ipynb
  • nbs/docs/tutorials/StatisticalNeuralMethods.ipynb
  • nbs/docs/tutorials/GARCH_tutorial.ipynb
  • nbs/docs/tutorials/AnomalyDetection.ipynb
  • nbs/docs/tutorials/ElectricityPeakForecasting.ipynb
  • nbs/docs/tutorials/MultipleSeasonalities.ipynb
  • nbs/docs/tutorials/ConformalPrediction.ipynb
  • nbs/docs/tutorials/UncertaintyIntervals.ipynb
  • nbs/docs/tutorials/CrossValidation.ipynb
  • nbs/docs/tutorials/ElectricityLoadForecasting.ipynb
  • nbs/docs/tutorials/IntermittentData.ipynb

If you want to contribute please comment the name of the notebook(s) that you want to work on. The process consists of:

  1. Verifying that the notebook has problems. You can use the following script, suppose you name it docs_check.py:
import sys

from execnb.nbio import read_nb
from nbdev.processors import FilterDefaults

fname = sys.argv[1]
nb = read_nb(fname)
FilterDefaults()(nb)

and then run it like: python docs_check.py nbs/src/utils.ipynb. Right now this gives me the following:

/hdd/github/nbdev/nbdev/processors.py:186: UserWarning: Found cells containing imports and other code. See FAQ.
---
from statsforecast.utils import AirPassengersDF

AirPassengersDF.head(12)
---

  warn(f'Found cells containing imports and other code. See FAQ.\n---\n{cell.source}\n---\n')
  1. If you see a warning like that, you have to split that cell. In this case move from statsforecast.utils import AirPassengersDF to an isolated cell above. If you don't get a warning you can just comment that a specific notebook doesn't have a problem and we'll mark it as done in the checklist.

@patrick-dd
Copy link
Contributor

I've gone through all the notebooks. The above PR has the required changes.

@jmoralez jmoralez linked a pull request Nov 10, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants