Nbdev v2 launched

3 Likes

Today I have skim through the directive page and best practice of nbdev. They are super amazing!

First of all, I remembered I requested this feature, and Jeremy said will think about it. Here it is! Thank you nbdev team so much for creating this directive! :rocket: :+1:

This directive is super useful :+1: when I use run nbdev_prepare on a notebook with training models.

I love this one too!

2 Likes

When I set recursive=True as suggested, it seems that nbdev does something else besides including subfolders in notebook globs. For example, I think it runs cells that are explicitly marked not to be evaluated. My impression is that it ignores #| eval: false and

skip_showdoc: true
skip_exec: true

Interesting. Could you share more? Perhaps a link your repo?

Not in my case. They are not executed when I do nbdev_prepare

Hi guys,

Is there a way to export a function includes codes which contains % or %% like the one below?

#| export
def reload():
    %load_ext autoreload
    %autoreload 2
reload()    

I have raised the question here previously

Note that this question is duplicated and was cross-posted on this GitHub Issue

I will try to recreate the problem I saw with a minimal example and open a new issue if necessary. Therefore, this question is no longer tracked on the issue mentioned by @hamelsmu.

Thanks, I certainly missed it.

1 Like

I found #| export othermodule not working stably in my project, but I received no error or warning on this behavior.

I ask to export to a module named “delete0002” as below in this notebook

Then I want to export the function named “get_exp_data” to a different module, here I tried 4 modules, it succeeded on the oldest two modules, not failed to all the newly created modules. And I have received no errors on this behavior.

I have no idea why it is so, could you have a look? Thanks

Some other Nb needs to set those modules as default_exp

1 Like

Thank you so much Jeremy for your reply!

It was not the cause to the problem as I did make sure all those Nbs have their own modules as default_exp as you can see their modules below, and the current notebook’s module is delete0002 which is also created below.

Hmmm… Maybe the filenames need to be sorted so earlier filenames set the default_exp before others add to their modules?

(sorry I don’t use this feature myself so am not so familiar with it)

1 Like

Thanks a lot Jeremy! I guess what you mean is that when nbdev tries to export to other modules, it failed because at the moment the module itself is not ready. So, sorting the filenames to ensure all the modules are generated before the action of exporting to other module is executed, could be the solution.

So, to verify this hypothesis I have checked the order of filenames when nbdev_preview, and the order of the filenames supports the hypothesis above. The notebook I am doing export to other modules is after core.py and utils.py but before all other modules are made.

Then my question is how do I sort the filenames, I have tried to removed the numbers in the filenames, so far there is no luck.


Now, it exported to the modules I wanted. I guess the order has been changed, though I can’t see it because sometimes nbdev_preview does not show me the order of all the filenames.

How to view the website generated by nbdev in a localhost on paperspace?

I have managed to use nbdev with my project on paperspace, and nbdev_preview works fine too, until it gives me the localhost link. I don’t know where to paste the link to view the generated website. Well, I didn’t try to paste it to the end of the url of paperspace, and it didn’t work of course.

Could anyone help here? thanks!

Hi Daniel,

At the moment, we do not support port forwarding on Gradient machines. However, you can control forwarded ports on a Paperspace Core machine. You can run this notebook there and then access the site on your local browser if you forward port 4151.

Hope this helps

3 Likes

Thank you Joshua! It’s good to know Core machines can solve this problem for me.

1 Like

The data type of a function argument shows the entire module path in the documentation generated by nbdev, and it looks strange, like the screenshot below:

The code used in the case above looks like this:

from typing import Optional
from tensorflow.keras.layers import Normalization

#|export
def keras_lasso_linear_model(
    ...
    normalization_layer: Optional[Normalization]=None,
   ...
) -> tf.keras.Sequential:

Is it possible to make this data type column in the documentation cleaner?

Another question related to the documentation: It seems that nbdev inherits the base class documentation even when I explicitly add a docstring to my class. Example:

#|export
class LinearHyperModel(kt.HyperModel):
    def __init__(
        self,
        number_documents_per_query, 
        number_features,
        top_n=10,
        learning_rate_range=None,
    ):
        """
        Define a KerasTuner search space for linear models
        """
        # code here

leads to
docs_inheritance

where the text comes from the kt.HyperModel base class. Is this the expected behavior?

Does it change if you put the docstring on the class, instead of the init?