jupyterlab / jupyterlab

JupyterLab computational environment.
https://jupyterlab.readthedocs.io/
Other
13.81k stars 3.12k forks source link

Date shows "next year" when creating or saving a notebook #16254

Open nuvious opened 2 weeks ago

nuvious commented 2 weeks ago

Description

Last Modified date shows "next year" for new notebooks and existing notebooks soon after being saved, especially while under a heavy processing load.

Reproduce

  1. Create a new notebook:

image

  1. Click on File > Save Notebook/Press CTRL+S/Click Save Button and save the notebook

image

  1. Add some code that will take a long time to process, run it, and then click save:

before

after clicking save

Diagnosed and narrowed the issue down to Time.formatHuman function in jupyter/jupyterlab/packages/coreutils/src/time.ts. If you set a breakpoint after delta is calculated it is sometimes a positive value. My guess is this is due to some asynchronous execution resulting in the save time appearing before the Date.now() time.

image

With delta (s) being a positive value, the result of Math.ceil(delta / unit.milliseconds) for any of the units will be 1. The first unit in the list is { name: 'years', milliseconds: 365 * 24 * 60 * 60 * 1000 } and thus with amount being non-zero return formatter.format(amount, unit.name); on line 57 has the values 1, "year" and is formatted to "next year".

A simple check to see if s is positive and return formatter.format(0, 'seconds'); if it is will resolve the issue and a PR is to follow submitted by me; just wanted to get the issue documented first.

Expected behavior

Expect it to show "0 seconds" or "now" or whatever makes sense based on notebook language settings.

Context

Troubleshoot Output
$PATH:
        /home/nuvious/EN.695.737.81.SP24-ArtificialIntelligenceForAssuredAutonomy/.venv/bin
        /home/nuvious/.vscode-server/cli/servers/Stable-e170252f762678dec6ca2cc69aba1570769a5d39/server/bin/remote-cli
        /usr/local/bin
        /usr/bin
        /bin
        /usr/local/games
        /usr/games

sys.path:
        /home/nuvious/EN.695.737.81.SP24-ArtificialIntelligenceForAssuredAutonomy/.venv/bin
        /usr/lib/python311.zip
        /usr/lib/python3.11
        /usr/lib/python3.11/lib-dynload
        /home/nuvious/EN.695.737.81.SP24-ArtificialIntelligenceForAssuredAutonomy/.venv/lib/python3.11/site-packages

sys.executable:
        /home/nuvious/EN.695.737.81.SP24-ArtificialIntelligenceForAssuredAutonomy/.venv/bin/python3

sys.version:
        3.11.2 (main, Mar 13 2023, 12:18:29) [GCC 12.2.0]

platform.platform():
        Linux-6.1.0-18-amd64-x86_64-with-glibc2.36

which -a jupyter:
        /home/nuvious/EN.695.737.81.SP24-ArtificialIntelligenceForAssuredAutonomy/.venv/bin/jupyter

pip list:
        Package                      Version
        ---------------------------- --------------
        absl-py                      2.1.0
        amalgam-lang                 10.0.0
        anyio                        4.3.0
        argon2-cffi                  23.1.0
        argon2-cffi-bindings         21.2.0
        arrow                        1.3.0
        asttokens                    2.4.1
        astunparse                   1.6.3
        async-lru                    2.0.4
        attrs                        23.2.0
        Babel                        2.14.0
        bayesian-optimization        1.4.3
        beautifulsoup4               4.12.3
        bleach                       6.1.0
        certifi                      2024.2.2
        cffi                         1.16.0
        charset-normalizer           3.3.2
        cloudpickle                  3.0.0
        colorama                     0.4.6
        comm                         0.2.2
        contourpy                    1.2.0
        cryptography                 42.0.5
        cycler                       0.12.1
        debugpy                      1.8.1
        decorator                    5.1.1
        defusedxml                   0.7.1
        deprecation                  2.1.0
        executing                    2.0.1
        Faker                        24.3.0
        fastjsonschema               2.19.1
        flatbuffers                  24.3.7
        fonttools                    4.50.0
        fqdn                         1.5.1
        gast                         0.5.4
        google-pasta                 0.2.0
        grpcio                       1.62.1
        h11                          0.14.0
        h5py                         3.10.0
        howso-engine                 19.0.0
        howso-openapi-client         32.0.0
        httpcore                     1.0.4
        httpx                        0.27.0
        humanize                     4.9.0
        idna                         3.6
        imageio                      2.34.1
        ipykernel                    6.29.3
        ipython                      8.22.2
        ipywidgets                   8.1.2
        isoduration                  20.11.0
        jedi                         0.19.1
        Jinja2                       3.1.3
        joblib                       1.3.2
        json5                        0.9.24
        jsonpointer                  2.4
        jsonschema                   4.21.1
        jsonschema-specifications    2023.12.1
        jupyter                      1.0.0
        jupyter_client               8.6.1
        jupyter-console              6.6.3
        jupyter_core                 5.7.2
        jupyter-events               0.10.0
        jupyter-lsp                  2.2.4
        jupyter_server               2.13.0
        jupyter_server_terminals     0.5.3
        jupyterlab                   4.1.5
        jupyterlab_pygments          0.3.0
        jupyterlab_server            2.25.4
        jupyterlab_widgets           3.0.10
        keras                        3.1.1
        kiwisolver                   1.4.5
        lazy_loader                  0.4
        libclang                     18.1.1
        lime                         0.2.0.1
        llvmlite                     0.42.0
        Markdown                     3.6
        markdown-it-py               3.0.0
        MarkupSafe                   2.1.5
        matplotlib                   3.8.3
        matplotlib-inline            0.1.6
        mdurl                        0.1.2
        mistune                      3.0.2
        ml-dtypes                    0.3.2
        mmh3                         4.1.0
        namex                        0.0.7
        nbclient                     0.10.0
        nbconvert                    7.16.3
        nbformat                     5.10.3
        nest-asyncio                 1.6.0
        networkx                     3.3
        notebook                     7.1.2
        notebook_shim                0.2.4
        numba                        0.59.1
        numpy                        1.26.4
        opt-einsum                   3.3.0
        optree                       0.10.0
        overrides                    7.7.0
        packaging                    24.0
        pandas                       2.2.1
        pandocfilters                1.5.1
        parso                        0.8.3
        pexpect                      4.9.0
        pillow                       10.2.0
        pip                          23.0.1
        platformdirs                 4.2.0
        prometheus_client            0.20.0
        prompt-toolkit               3.0.43
        protobuf                     4.25.3
        psutil                       5.9.8
        ptyprocess                   0.7.0
        pure-eval                    0.2.2
        pycparser                    2.21
        pygad                        3.3.1
        Pygments                     2.17.2
        PyJWT                        2.8.0
        pyparsing                    3.1.2
        python-dateutil              2.9.0.post0
        python-json-logger           2.0.7
        pytz                         2024.1
        PyYAML                       6.0.1
        pyzmq                        25.1.2
        qtconsole                    5.5.1
        QtPy                         2.4.1
        referencing                  0.34.0
        requests                     2.31.0
        rfc3339-validator            0.1.4
        rfc3986-validator            0.1.1
        rich                         13.7.1
        rpds-py                      0.18.0
        scikit-image                 0.23.2
        scikit-learn                 1.4.1.post1
        scipy                        1.12.0
        semantic-version             2.10.0
        Send2Trash                   1.8.2
        setuptools                   66.1.1
        shap                         0.45.0
        six                          1.16.0
        slicer                       0.0.7
        sniffio                      1.3.1
        soupsieve                    2.5
        stack-data                   0.6.3
        tensorboard                  2.16.2
        tensorboard-data-server      0.7.2
        tensorflow                   2.16.1
        tensorflow-io-gcs-filesystem 0.36.0
        termcolor                    2.4.0
        terminado                    0.18.1
        threadpoolctl                3.4.0
        tifffile                     2024.4.24
        tinycss2                     1.2.1
        tornado                      6.4
        tqdm                         4.66.2
        traitlets                    5.14.2
        types-python-dateutil        2.9.0.20240316
        typing_extensions            4.10.0
        tzdata                       2024.1
        uri-template                 1.3.0
        urllib3                      2.2.1
        wcwidth                      0.2.13
        webcolors                    1.13
        webencodings                 0.5.1
        websocket-client             1.7.0
        Werkzeug                     3.0.1
        wheel                        0.43.0
        widgetsnbextension           4.0.10
        wrapt                        1.16.0
Command Line Output
N/A - Does not throw an exception and source of issue was isolated with javascript/typescript debugging and static
analysis.
Browser Output
See screenshot for specific issue found in TypeScript
welcome[bot] commented 2 weeks ago

Thank you for opening your first issue in this project! Engagement like this is essential for open source projects! :hugs:
If you haven't done so already, check out Jupyter's Code of Conduct. Also, please try to follow the issue template as it helps other other community members to contribute more effectively. welcome You can meet the other Jovyans by joining our Discourse forum. There is also an intro thread there where you can stop by and say Hi! :wave:
Welcome to the Jupyter community! :tada: