├── .copier-answers.yml ├── .github └── workflows │ ├── binder-on-pr.yml │ ├── build.yml │ ├── check-release.yml │ ├── enforce-label.yml │ ├── prep-release.yml │ └── publish-release.yml ├── .gitignore ├── .prettierignore ├── .yarnrc.yml ├── 2025-02-20-184635_4480x1440_scrot.png ├── LICENSE ├── README.md ├── RELEASE.md ├── binder ├── environment.yml └── postBuild ├── build.sh ├── install.json ├── media ├── jupyter-variable-inspector-banner.jpg ├── jupyter-variable-inspector-display-data-frame.gif ├── jupyter-variable-inspector-update-data.gif └── jupyter-variable-inspector.gif ├── package.json ├── pyproject.toml ├── schema └── plugin.json ├── setup.py ├── src ├── components │ ├── paginationControls.tsx │ ├── searchBar.tsx │ ├── variableInspectorPanel.ts │ ├── variableInspectorSidebar.tsx │ ├── variableItem.tsx │ ├── variableList.tsx │ ├── variableListComponent.tsx │ ├── variablePanel.tsx │ ├── variablePanelWidget.tsx │ ├── variableRefreshButton.tsx │ └── variableSettingsButton.tsx ├── context │ ├── codeExecutionContext.tsx │ ├── notebookKernelContext.tsx │ ├── notebookPanelContext.tsx │ ├── notebookVariableContext.tsx │ ├── pluginVisibilityContext.tsx │ ├── themeContext.tsx │ └── variableRefershContext.tsx ├── icons │ ├── checkIcon.ts │ ├── detailIcon.ts │ ├── gridScanIcon.ts │ ├── panelIcon.ts │ ├── pluginIcon.ts │ ├── refreshIcon.ts │ ├── settingsIcon.ts │ ├── skipLeftIcon.ts │ ├── skipRightIcon.ts │ ├── smallSkipLeftIcon.ts │ └── smallSkipRightIcon.ts ├── index.ts ├── python_code │ ├── getMatrix.ts │ └── getVariables.ts ├── utils │ ├── allowedTypes.ts │ ├── executeGetMatrix.ts │ ├── globalKernelTimeStamp.ts │ ├── kernelOperationNotifier.ts │ └── utils.ts └── watchers │ └── notebookWatcher.ts ├── style ├── base.css ├── index.css └── index.js ├── tsconfig.json ├── variable_inspector └── __init__.py └── yarn.lock /.copier-answers.yml: -------------------------------------------------------------------------------- 1 | # Changes here will be overwritten by Copier; NEVER EDIT MANUALLY 2 | _commit: v4.3.7 3 | _src_path: https://github.com/jupyterlab/extension-template 4 | author_email: contact@mljar.com 5 | author_name: variable-inscpector 6 | has_binder: true 7 | has_settings: true 8 | kind: frontend 9 | labextension_name: variable-inspector 10 | project_short_description: Variable inspector for jupyter lab. 11 | python_name: variable_inspector 12 | repository: https://github.com/mljar/variable-inspector.git 13 | test: false 14 | 15 | -------------------------------------------------------------------------------- /.github/workflows/binder-on-pr.yml: -------------------------------------------------------------------------------- 1 | name: Binder Badge 2 | on: 3 | pull_request_target: 4 | types: [opened] 5 | 6 | jobs: 7 | binder: 8 | runs-on: ubuntu-latest 9 | permissions: 10 | pull-requests: write 11 | steps: 12 | - uses: jupyterlab/maintainer-tools/.github/actions/binder-link@v1 13 | with: 14 | github_token: ${{ secrets.GITHUB_TOKEN }} 15 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Build 2 | 3 | on: 4 | pull_request: 5 | branches: '*' 6 | 7 | concurrency: 8 | group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} 9 | cancel-in-progress: true 10 | 11 | jobs: 12 | build: 13 | runs-on: ubuntu-latest 14 | 15 | steps: 16 | - name: Checkout 17 | uses: actions/checkout@v4 18 | 19 | - name: Base Setup 20 | uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1 21 | 22 | - name: Install dependencies 23 | run: python -m pip install -U "jupyterlab>=4.0.0,<5" 24 | 25 | - name: Lint the extension 26 | run: | 27 | set -eux 28 | jlpm 29 | jlpm run lint:check 30 | 31 | - name: Build the extension 32 | run: | 33 | set -eux 34 | python -m pip install .[test] 35 | 36 | jupyter labextension list 37 | jupyter labextension list 2>&1 | grep -ie "variable-inspector.*OK" 38 | python -m jupyterlab.browser_check 39 | 40 | - name: Package the extension 41 | run: | 42 | set -eux 43 | 44 | pip install build 45 | python -m build 46 | pip uninstall -y "variable_inspector" jupyterlab 47 | 48 | - name: Upload extension packages 49 | uses: actions/upload-artifact@v4 50 | with: 51 | name: extension-artifacts 52 | path: dist/variable_inspector* 53 | if-no-files-found: error 54 | 55 | test_isolated: 56 | needs: build 57 | runs-on: ubuntu-latest 58 | 59 | steps: 60 | - name: Install Python 61 | uses: actions/setup-python@v5 62 | with: 63 | python-version: '3.9' 64 | architecture: 'x64' 65 | - uses: actions/download-artifact@v4 66 | with: 67 | name: extension-artifacts 68 | - name: Install and Test 69 | run: | 70 | set -eux 71 | # Remove NodeJS, twice to take care of system and locally installed node versions. 72 | sudo rm -rf $(which node) 73 | sudo rm -rf $(which node) 74 | 75 | pip install "jupyterlab>=4.0.0,<5" variable_inspector*.whl 76 | 77 | 78 | jupyter labextension list 79 | jupyter labextension list 2>&1 | grep -ie "variable-inspector.*OK" 80 | python -m jupyterlab.browser_check --no-browser-test 81 | 82 | 83 | check_links: 84 | name: Check Links 85 | runs-on: ubuntu-latest 86 | timeout-minutes: 15 87 | steps: 88 | - uses: actions/checkout@v4 89 | - uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1 90 | - uses: jupyterlab/maintainer-tools/.github/actions/check-links@v1 91 | -------------------------------------------------------------------------------- /.github/workflows/check-release.yml: -------------------------------------------------------------------------------- 1 | name: Check Release 2 | on: 3 | pull_request: 4 | branches: ["*"] 5 | 6 | concurrency: 7 | group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} 8 | cancel-in-progress: true 9 | 10 | jobs: 11 | check_release: 12 | runs-on: ubuntu-latest 13 | steps: 14 | - name: Checkout 15 | uses: actions/checkout@v4 16 | - name: Base Setup 17 | uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1 18 | - name: Check Release 19 | uses: jupyter-server/jupyter_releaser/.github/actions/check-release@v2 20 | with: 21 | 22 | token: ${{ secrets.GITHUB_TOKEN }} 23 | 24 | - name: Upload Distributions 25 | uses: actions/upload-artifact@v4 26 | with: 27 | name: variable_inspector-releaser-dist-${{ github.run_number }} 28 | path: .jupyter_releaser_checkout/dist 29 | -------------------------------------------------------------------------------- /.github/workflows/enforce-label.yml: -------------------------------------------------------------------------------- 1 | name: Enforce PR label 2 | 3 | on: 4 | pull_request: 5 | types: [labeled, unlabeled, opened, edited, synchronize] 6 | jobs: 7 | enforce-label: 8 | runs-on: ubuntu-latest 9 | permissions: 10 | pull-requests: write 11 | steps: 12 | - name: enforce-triage-label 13 | uses: jupyterlab/maintainer-tools/.github/actions/enforce-label@v1 14 | -------------------------------------------------------------------------------- /.github/workflows/prep-release.yml: -------------------------------------------------------------------------------- 1 | name: "Step 1: Prep Release" 2 | on: 3 | workflow_dispatch: 4 | inputs: 5 | version_spec: 6 | description: "New Version Specifier" 7 | default: "next" 8 | required: false 9 | branch: 10 | description: "The branch to target" 11 | required: false 12 | post_version_spec: 13 | description: "Post Version Specifier" 14 | required: false 15 | # silent: 16 | # description: "Set a placeholder in the changelog and don't publish the release." 17 | # required: false 18 | # type: boolean 19 | since: 20 | description: "Use PRs with activity since this date or git reference" 21 | required: false 22 | since_last_stable: 23 | description: "Use PRs with activity since the last stable git tag" 24 | required: false 25 | type: boolean 26 | jobs: 27 | prep_release: 28 | runs-on: ubuntu-latest 29 | permissions: 30 | contents: write 31 | steps: 32 | - uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1 33 | 34 | - name: Prep Release 35 | id: prep-release 36 | uses: jupyter-server/jupyter_releaser/.github/actions/prep-release@v2 37 | with: 38 | token: ${{ secrets.GITHUB_TOKEN }} 39 | version_spec: ${{ github.event.inputs.version_spec }} 40 | # silent: ${{ github.event.inputs.silent }} 41 | post_version_spec: ${{ github.event.inputs.post_version_spec }} 42 | branch: ${{ github.event.inputs.branch }} 43 | since: ${{ github.event.inputs.since }} 44 | since_last_stable: ${{ github.event.inputs.since_last_stable }} 45 | 46 | - name: "** Next Step **" 47 | run: | 48 | echo "Optional): Review Draft Release: ${{ steps.prep-release.outputs.release_url }}" 49 | -------------------------------------------------------------------------------- /.github/workflows/publish-release.yml: -------------------------------------------------------------------------------- 1 | name: "Step 2: Publish Release" 2 | on: 3 | workflow_dispatch: 4 | inputs: 5 | branch: 6 | description: "The target branch" 7 | required: false 8 | release_url: 9 | description: "The URL of the draft GitHub release" 10 | required: false 11 | steps_to_skip: 12 | description: "Comma separated list of steps to skip" 13 | required: false 14 | 15 | jobs: 16 | publish_release: 17 | runs-on: ubuntu-latest 18 | environment: release 19 | permissions: 20 | id-token: write 21 | steps: 22 | - uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1 23 | 24 | - uses: actions/create-github-app-token@v1 25 | id: app-token 26 | with: 27 | app-id: ${{ vars.APP_ID }} 28 | private-key: ${{ secrets.APP_PRIVATE_KEY }} 29 | 30 | - name: Populate Release 31 | id: populate-release 32 | uses: jupyter-server/jupyter_releaser/.github/actions/populate-release@v2 33 | with: 34 | token: ${{ steps.app-token.outputs.token }} 35 | branch: ${{ github.event.inputs.branch }} 36 | release_url: ${{ github.event.inputs.release_url }} 37 | steps_to_skip: ${{ github.event.inputs.steps_to_skip }} 38 | 39 | - name: Finalize Release 40 | id: finalize-release 41 | env: 42 | NPM_TOKEN: ${{ secrets.NPM_TOKEN }} 43 | uses: jupyter-server/jupyter_releaser/.github/actions/finalize-release@v2 44 | with: 45 | token: ${{ steps.app-token.outputs.token }} 46 | release_url: ${{ steps.populate-release.outputs.release_url }} 47 | 48 | - name: "** Next Step **" 49 | if: ${{ success() }} 50 | run: | 51 | echo "Verify the final release" 52 | echo ${{ steps.finalize-release.outputs.release_url }} 53 | 54 | - name: "** Failure Message **" 55 | if: ${{ failure() }} 56 | run: | 57 | echo "Failed to Publish the Draft Release Url:" 58 | echo ${{ steps.populate-release.outputs.release_url }} 59 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.bundle.* 2 | lib/ 3 | node_modules/ 4 | *.log 5 | .eslintcache 6 | .stylelintcache 7 | *.egg-info/ 8 | .ipynb_checkpoints 9 | *.tsbuildinfo 10 | variable_inspector/labextension 11 | # Version file is handled by hatchling 12 | variable_inspector/_version.py 13 | 14 | # Created by https://www.gitignore.io/api/python 15 | # Edit at https://www.gitignore.io/?templates=python 16 | 17 | ### Python ### 18 | # Byte-compiled / optimized / DLL files 19 | __pycache__/ 20 | *.py[cod] 21 | *$py.class 22 | 23 | # C extensions 24 | *.so 25 | 26 | # Distribution / packaging 27 | .Python 28 | build/ 29 | develop-eggs/ 30 | dist/ 31 | downloads/ 32 | eggs/ 33 | .eggs/ 34 | lib/ 35 | lib64/ 36 | parts/ 37 | sdist/ 38 | var/ 39 | wheels/ 40 | pip-wheel-metadata/ 41 | share/python-wheels/ 42 | .installed.cfg 43 | *.egg 44 | MANIFEST 45 | 46 | # PyInstaller 47 | # Usually these files are written by a python script from a template 48 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 49 | *.manifest 50 | *.spec 51 | 52 | # Installer logs 53 | pip-log.txt 54 | pip-delete-this-directory.txt 55 | 56 | # Unit test / coverage reports 57 | htmlcov/ 58 | .tox/ 59 | .nox/ 60 | .coverage 61 | .coverage.* 62 | .cache 63 | nosetests.xml 64 | coverage/ 65 | coverage.xml 66 | *.cover 67 | .hypothesis/ 68 | .pytest_cache/ 69 | 70 | # Translations 71 | *.mo 72 | *.pot 73 | 74 | # Scrapy stuff: 75 | .scrapy 76 | 77 | # Sphinx documentation 78 | docs/_build/ 79 | 80 | # PyBuilder 81 | target/ 82 | 83 | # pyenv 84 | .python-version 85 | 86 | # celery beat schedule file 87 | celerybeat-schedule 88 | 89 | # SageMath parsed files 90 | *.sage.py 91 | 92 | # Spyder project settings 93 | .spyderproject 94 | .spyproject 95 | 96 | # Rope project settings 97 | .ropeproject 98 | 99 | # Mr Developer 100 | .mr.developer.cfg 101 | .project 102 | .pydevproject 103 | 104 | # mkdocs documentation 105 | /site 106 | 107 | # mypy 108 | .mypy_cache/ 109 | .dmypy.json 110 | dmypy.json 111 | 112 | # Pyre type checker 113 | .pyre/ 114 | 115 | # End of https://www.gitignore.io/api/python 116 | 117 | # OSX files 118 | .DS_Store 119 | 120 | # Yarn cache 121 | .yarn/ 122 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | **/node_modules 3 | **/lib 4 | **/package.json 5 | !/package.json 6 | variable_inspector 7 | -------------------------------------------------------------------------------- /.yarnrc.yml: -------------------------------------------------------------------------------- 1 | nodeLinker: node-modules 2 | -------------------------------------------------------------------------------- /2025-02-20-184635_4480x1440_scrot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mljar/variable-inspector/f585c4299d13ce8b39713d51a5ce1ebec0f2926a/2025-02-20-184635_4480x1440_scrot.png -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU AFFERO GENERAL PUBLIC LICENSE 2 | Version 3, 19 November 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU Affero General Public License is a free, copyleft license for 11 | software and other kinds of works, specifically designed to ensure 12 | cooperation with the community in the case of network server software. 13 | 14 | The licenses for most software and other practical works are designed 15 | to take away your freedom to share and change the works. By contrast, 16 | our General Public Licenses are intended to guarantee your freedom to 17 | share and change all versions of a program--to make sure it remains free 18 | software for all its users. 19 | 20 | When we speak of free software, we are referring to freedom, not 21 | price. Our General Public Licenses are designed to make sure that you 22 | have the freedom to distribute copies of free software (and charge for 23 | them if you wish), that you receive source code or can get it if you 24 | want it, that you can change the software or use pieces of it in new 25 | free programs, and that you know you can do these things. 26 | 27 | Developers that use our General Public Licenses protect your rights 28 | with two steps: (1) assert copyright on the software, and (2) offer 29 | you this License which gives you legal permission to copy, distribute 30 | and/or modify the software. 31 | 32 | A secondary benefit of defending all users' freedom is that 33 | improvements made in alternate versions of the program, if they 34 | receive widespread use, become available for other developers to 35 | incorporate. Many developers of free software are heartened and 36 | encouraged by the resulting cooperation. However, in the case of 37 | software used on network servers, this result may fail to come about. 38 | The GNU General Public License permits making a modified version and 39 | letting the public access it on a server without ever releasing its 40 | source code to the public. 41 | 42 | The GNU Affero General Public License is designed specifically to 43 | ensure that, in such cases, the modified source code becomes available 44 | to the community. It requires the operator of a network server to 45 | provide the source code of the modified version running there to the 46 | users of that server. Therefore, public use of a modified version, on 47 | a publicly accessible server, gives the public access to the source 48 | code of the modified version. 49 | 50 | An older license, called the Affero General Public License and 51 | published by Affero, was designed to accomplish similar goals. This is 52 | a different license, not a version of the Affero GPL, but Affero has 53 | released a new version of the Affero GPL which permits relicensing under 54 | this license. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | TERMS AND CONDITIONS 60 | 61 | 0. Definitions. 62 | 63 | "This License" refers to version 3 of the GNU Affero General Public License. 64 | 65 | "Copyright" also means copyright-like laws that apply to other kinds of 66 | works, such as semiconductor masks. 67 | 68 | "The Program" refers to any copyrightable work licensed under this 69 | License. Each licensee is addressed as "you". "Licensees" and 70 | "recipients" may be individuals or organizations. 71 | 72 | To "modify" a work means to copy from or adapt all or part of the work 73 | in a fashion requiring copyright permission, other than the making of an 74 | exact copy. The resulting work is called a "modified version" of the 75 | earlier work or a work "based on" the earlier work. 76 | 77 | A "covered work" means either the unmodified Program or a work based 78 | on the Program. 79 | 80 | To "propagate" a work means to do anything with it that, without 81 | permission, would make you directly or secondarily liable for 82 | infringement under applicable copyright law, except executing it on a 83 | computer or modifying a private copy. Propagation includes copying, 84 | distribution (with or without modification), making available to the 85 | public, and in some countries other activities as well. 86 | 87 | To "convey" a work means any kind of propagation that enables other 88 | parties to make or receive copies. Mere interaction with a user through 89 | a computer network, with no transfer of a copy, is not conveying. 90 | 91 | An interactive user interface displays "Appropriate Legal Notices" 92 | to the extent that it includes a convenient and prominently visible 93 | feature that (1) displays an appropriate copyright notice, and (2) 94 | tells the user that there is no warranty for the work (except to the 95 | extent that warranties are provided), that licensees may convey the 96 | work under this License, and how to view a copy of this License. If 97 | the interface presents a list of user commands or options, such as a 98 | menu, a prominent item in the list meets this criterion. 99 | 100 | 1. Source Code. 101 | 102 | The "source code" for a work means the preferred form of the work 103 | for making modifications to it. "Object code" means any non-source 104 | form of a work. 105 | 106 | A "Standard Interface" means an interface that either is an official 107 | standard defined by a recognized standards body, or, in the case of 108 | interfaces specified for a particular programming language, one that 109 | is widely used among developers working in that language. 110 | 111 | The "System Libraries" of an executable work include anything, other 112 | than the work as a whole, that (a) is included in the normal form of 113 | packaging a Major Component, but which is not part of that Major 114 | Component, and (b) serves only to enable use of the work with that 115 | Major Component, or to implement a Standard Interface for which an 116 | implementation is available to the public in source code form. A 117 | "Major Component", in this context, means a major essential component 118 | (kernel, window system, and so on) of the specific operating system 119 | (if any) on which the executable work runs, or a compiler used to 120 | produce the work, or an object code interpreter used to run it. 121 | 122 | The "Corresponding Source" for a work in object code form means all 123 | the source code needed to generate, install, and (for an executable 124 | work) run the object code and to modify the work, including scripts to 125 | control those activities. However, it does not include the work's 126 | System Libraries, or general-purpose tools or generally available free 127 | programs which are used unmodified in performing those activities but 128 | which are not part of the work. For example, Corresponding Source 129 | includes interface definition files associated with source files for 130 | the work, and the source code for shared libraries and dynamically 131 | linked subprograms that the work is specifically designed to require, 132 | such as by intimate data communication or control flow between those 133 | subprograms and other parts of the work. 134 | 135 | The Corresponding Source need not include anything that users 136 | can regenerate automatically from other parts of the Corresponding 137 | Source. 138 | 139 | The Corresponding Source for a work in source code form is that 140 | same work. 141 | 142 | 2. Basic Permissions. 143 | 144 | All rights granted under this License are granted for the term of 145 | copyright on the Program, and are irrevocable provided the stated 146 | conditions are met. This License explicitly affirms your unlimited 147 | permission to run the unmodified Program. The output from running a 148 | covered work is covered by this License only if the output, given its 149 | content, constitutes a covered work. This License acknowledges your 150 | rights of fair use or other equivalent, as provided by copyright law. 151 | 152 | You may make, run and propagate covered works that you do not 153 | convey, without conditions so long as your license otherwise remains 154 | in force. You may convey covered works to others for the sole purpose 155 | of having them make modifications exclusively for you, or provide you 156 | with facilities for running those works, provided that you comply with 157 | the terms of this License in conveying all material for which you do 158 | not control copyright. Those thus making or running the covered works 159 | for you must do so exclusively on your behalf, under your direction 160 | and control, on terms that prohibit them from making any copies of 161 | your copyrighted material outside their relationship with you. 162 | 163 | Conveying under any other circumstances is permitted solely under 164 | the conditions stated below. Sublicensing is not allowed; section 10 165 | makes it unnecessary. 166 | 167 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 168 | 169 | No covered work shall be deemed part of an effective technological 170 | measure under any applicable law fulfilling obligations under article 171 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 172 | similar laws prohibiting or restricting circumvention of such 173 | measures. 174 | 175 | When you convey a covered work, you waive any legal power to forbid 176 | circumvention of technological measures to the extent such circumvention 177 | is effected by exercising rights under this License with respect to 178 | the covered work, and you disclaim any intention to limit operation or 179 | modification of the work as a means of enforcing, against the work's 180 | users, your or third parties' legal rights to forbid circumvention of 181 | technological measures. 182 | 183 | 4. Conveying Verbatim Copies. 184 | 185 | You may convey verbatim copies of the Program's source code as you 186 | receive it, in any medium, provided that you conspicuously and 187 | appropriately publish on each copy an appropriate copyright notice; 188 | keep intact all notices stating that this License and any 189 | non-permissive terms added in accord with section 7 apply to the code; 190 | keep intact all notices of the absence of any warranty; and give all 191 | recipients a copy of this License along with the Program. 192 | 193 | You may charge any price or no price for each copy that you convey, 194 | and you may offer support or warranty protection for a fee. 195 | 196 | 5. Conveying Modified Source Versions. 197 | 198 | You may convey a work based on the Program, or the modifications to 199 | produce it from the Program, in the form of source code under the 200 | terms of section 4, provided that you also meet all of these conditions: 201 | 202 | a) The work must carry prominent notices stating that you modified 203 | it, and giving a relevant date. 204 | 205 | b) The work must carry prominent notices stating that it is 206 | released under this License and any conditions added under section 207 | 7. This requirement modifies the requirement in section 4 to 208 | "keep intact all notices". 209 | 210 | c) You must license the entire work, as a whole, under this 211 | License to anyone who comes into possession of a copy. This 212 | License will therefore apply, along with any applicable section 7 213 | additional terms, to the whole of the work, and all its parts, 214 | regardless of how they are packaged. This License gives no 215 | permission to license the work in any other way, but it does not 216 | invalidate such permission if you have separately received it. 217 | 218 | d) If the work has interactive user interfaces, each must display 219 | Appropriate Legal Notices; however, if the Program has interactive 220 | interfaces that do not display Appropriate Legal Notices, your 221 | work need not make them do so. 222 | 223 | A compilation of a covered work with other separate and independent 224 | works, which are not by their nature extensions of the covered work, 225 | and which are not combined with it such as to form a larger program, 226 | in or on a volume of a storage or distribution medium, is called an 227 | "aggregate" if the compilation and its resulting copyright are not 228 | used to limit the access or legal rights of the compilation's users 229 | beyond what the individual works permit. Inclusion of a covered work 230 | in an aggregate does not cause this License to apply to the other 231 | parts of the aggregate. 232 | 233 | 6. Conveying Non-Source Forms. 234 | 235 | You may convey a covered work in object code form under the terms 236 | of sections 4 and 5, provided that you also convey the 237 | machine-readable Corresponding Source under the terms of this License, 238 | in one of these ways: 239 | 240 | a) Convey the object code in, or embodied in, a physical product 241 | (including a physical distribution medium), accompanied by the 242 | Corresponding Source fixed on a durable physical medium 243 | customarily used for software interchange. 244 | 245 | b) Convey the object code in, or embodied in, a physical product 246 | (including a physical distribution medium), accompanied by a 247 | written offer, valid for at least three years and valid for as 248 | long as you offer spare parts or customer support for that product 249 | model, to give anyone who possesses the object code either (1) a 250 | copy of the Corresponding Source for all the software in the 251 | product that is covered by this License, on a durable physical 252 | medium customarily used for software interchange, for a price no 253 | more than your reasonable cost of physically performing this 254 | conveying of source, or (2) access to copy the 255 | Corresponding Source from a network server at no charge. 256 | 257 | c) Convey individual copies of the object code with a copy of the 258 | written offer to provide the Corresponding Source. This 259 | alternative is allowed only occasionally and noncommercially, and 260 | only if you received the object code with such an offer, in accord 261 | with subsection 6b. 262 | 263 | d) Convey the object code by offering access from a designated 264 | place (gratis or for a charge), and offer equivalent access to the 265 | Corresponding Source in the same way through the same place at no 266 | further charge. You need not require recipients to copy the 267 | Corresponding Source along with the object code. If the place to 268 | copy the object code is a network server, the Corresponding Source 269 | may be on a different server (operated by you or a third party) 270 | that supports equivalent copying facilities, provided you maintain 271 | clear directions next to the object code saying where to find the 272 | Corresponding Source. Regardless of what server hosts the 273 | Corresponding Source, you remain obligated to ensure that it is 274 | available for as long as needed to satisfy these requirements. 275 | 276 | e) Convey the object code using peer-to-peer transmission, provided 277 | you inform other peers where the object code and Corresponding 278 | Source of the work are being offered to the general public at no 279 | charge under subsection 6d. 280 | 281 | A separable portion of the object code, whose source code is excluded 282 | from the Corresponding Source as a System Library, need not be 283 | included in conveying the object code work. 284 | 285 | A "User Product" is either (1) a "consumer product", which means any 286 | tangible personal property which is normally used for personal, family, 287 | or household purposes, or (2) anything designed or sold for incorporation 288 | into a dwelling. In determining whether a product is a consumer product, 289 | doubtful cases shall be resolved in favor of coverage. For a particular 290 | product received by a particular user, "normally used" refers to a 291 | typical or common use of that class of product, regardless of the status 292 | of the particular user or of the way in which the particular user 293 | actually uses, or expects or is expected to use, the product. A product 294 | is a consumer product regardless of whether the product has substantial 295 | commercial, industrial or non-consumer uses, unless such uses represent 296 | the only significant mode of use of the product. 297 | 298 | "Installation Information" for a User Product means any methods, 299 | procedures, authorization keys, or other information required to install 300 | and execute modified versions of a covered work in that User Product from 301 | a modified version of its Corresponding Source. The information must 302 | suffice to ensure that the continued functioning of the modified object 303 | code is in no case prevented or interfered with solely because 304 | modification has been made. 305 | 306 | If you convey an object code work under this section in, or with, or 307 | specifically for use in, a User Product, and the conveying occurs as 308 | part of a transaction in which the right of possession and use of the 309 | User Product is transferred to the recipient in perpetuity or for a 310 | fixed term (regardless of how the transaction is characterized), the 311 | Corresponding Source conveyed under this section must be accompanied 312 | by the Installation Information. But this requirement does not apply 313 | if neither you nor any third party retains the ability to install 314 | modified object code on the User Product (for example, the work has 315 | been installed in ROM). 316 | 317 | The requirement to provide Installation Information does not include a 318 | requirement to continue to provide support service, warranty, or updates 319 | for a work that has been modified or installed by the recipient, or for 320 | the User Product in which it has been modified or installed. Access to a 321 | network may be denied when the modification itself materially and 322 | adversely affects the operation of the network or violates the rules and 323 | protocols for communication across the network. 324 | 325 | Corresponding Source conveyed, and Installation Information provided, 326 | in accord with this section must be in a format that is publicly 327 | documented (and with an implementation available to the public in 328 | source code form), and must require no special password or key for 329 | unpacking, reading or copying. 330 | 331 | 7. Additional Terms. 332 | 333 | "Additional permissions" are terms that supplement the terms of this 334 | License by making exceptions from one or more of its conditions. 335 | Additional permissions that are applicable to the entire Program shall 336 | be treated as though they were included in this License, to the extent 337 | that they are valid under applicable law. If additional permissions 338 | apply only to part of the Program, that part may be used separately 339 | under those permissions, but the entire Program remains governed by 340 | this License without regard to the additional permissions. 341 | 342 | When you convey a copy of a covered work, you may at your option 343 | remove any additional permissions from that copy, or from any part of 344 | it. (Additional permissions may be written to require their own 345 | removal in certain cases when you modify the work.) You may place 346 | additional permissions on material, added by you to a covered work, 347 | for which you have or can give appropriate copyright permission. 348 | 349 | Notwithstanding any other provision of this License, for material you 350 | add to a covered work, you may (if authorized by the copyright holders of 351 | that material) supplement the terms of this License with terms: 352 | 353 | a) Disclaiming warranty or limiting liability differently from the 354 | terms of sections 15 and 16 of this License; or 355 | 356 | b) Requiring preservation of specified reasonable legal notices or 357 | author attributions in that material or in the Appropriate Legal 358 | Notices displayed by works containing it; or 359 | 360 | c) Prohibiting misrepresentation of the origin of that material, or 361 | requiring that modified versions of such material be marked in 362 | reasonable ways as different from the original version; or 363 | 364 | d) Limiting the use for publicity purposes of names of licensors or 365 | authors of the material; or 366 | 367 | e) Declining to grant rights under trademark law for use of some 368 | trade names, trademarks, or service marks; or 369 | 370 | f) Requiring indemnification of licensors and authors of that 371 | material by anyone who conveys the material (or modified versions of 372 | it) with contractual assumptions of liability to the recipient, for 373 | any liability that these contractual assumptions directly impose on 374 | those licensors and authors. 375 | 376 | All other non-permissive additional terms are considered "further 377 | restrictions" within the meaning of section 10. If the Program as you 378 | received it, or any part of it, contains a notice stating that it is 379 | governed by this License along with a term that is a further 380 | restriction, you may remove that term. If a license document contains 381 | a further restriction but permits relicensing or conveying under this 382 | License, you may add to a covered work material governed by the terms 383 | of that license document, provided that the further restriction does 384 | not survive such relicensing or conveying. 385 | 386 | If you add terms to a covered work in accord with this section, you 387 | must place, in the relevant source files, a statement of the 388 | additional terms that apply to those files, or a notice indicating 389 | where to find the applicable terms. 390 | 391 | Additional terms, permissive or non-permissive, may be stated in the 392 | form of a separately written license, or stated as exceptions; 393 | the above requirements apply either way. 394 | 395 | 8. Termination. 396 | 397 | You may not propagate or modify a covered work except as expressly 398 | provided under this License. Any attempt otherwise to propagate or 399 | modify it is void, and will automatically terminate your rights under 400 | this License (including any patent licenses granted under the third 401 | paragraph of section 11). 402 | 403 | However, if you cease all violation of this License, then your 404 | license from a particular copyright holder is reinstated (a) 405 | provisionally, unless and until the copyright holder explicitly and 406 | finally terminates your license, and (b) permanently, if the copyright 407 | holder fails to notify you of the violation by some reasonable means 408 | prior to 60 days after the cessation. 409 | 410 | Moreover, your license from a particular copyright holder is 411 | reinstated permanently if the copyright holder notifies you of the 412 | violation by some reasonable means, this is the first time you have 413 | received notice of violation of this License (for any work) from that 414 | copyright holder, and you cure the violation prior to 30 days after 415 | your receipt of the notice. 416 | 417 | Termination of your rights under this section does not terminate the 418 | licenses of parties who have received copies or rights from you under 419 | this License. If your rights have been terminated and not permanently 420 | reinstated, you do not qualify to receive new licenses for the same 421 | material under section 10. 422 | 423 | 9. Acceptance Not Required for Having Copies. 424 | 425 | You are not required to accept this License in order to receive or 426 | run a copy of the Program. Ancillary propagation of a covered work 427 | occurring solely as a consequence of using peer-to-peer transmission 428 | to receive a copy likewise does not require acceptance. However, 429 | nothing other than this License grants you permission to propagate or 430 | modify any covered work. These actions infringe copyright if you do 431 | not accept this License. Therefore, by modifying or propagating a 432 | covered work, you indicate your acceptance of this License to do so. 433 | 434 | 10. Automatic Licensing of Downstream Recipients. 435 | 436 | Each time you convey a covered work, the recipient automatically 437 | receives a license from the original licensors, to run, modify and 438 | propagate that work, subject to this License. You are not responsible 439 | for enforcing compliance by third parties with this License. 440 | 441 | An "entity transaction" is a transaction transferring control of an 442 | organization, or substantially all assets of one, or subdividing an 443 | organization, or merging organizations. If propagation of a covered 444 | work results from an entity transaction, each party to that 445 | transaction who receives a copy of the work also receives whatever 446 | licenses to the work the party's predecessor in interest had or could 447 | give under the previous paragraph, plus a right to possession of the 448 | Corresponding Source of the work from the predecessor in interest, if 449 | the predecessor has it or can get it with reasonable efforts. 450 | 451 | You may not impose any further restrictions on the exercise of the 452 | rights granted or affirmed under this License. For example, you may 453 | not impose a license fee, royalty, or other charge for exercise of 454 | rights granted under this License, and you may not initiate litigation 455 | (including a cross-claim or counterclaim in a lawsuit) alleging that 456 | any patent claim is infringed by making, using, selling, offering for 457 | sale, or importing the Program or any portion of it. 458 | 459 | 11. Patents. 460 | 461 | A "contributor" is a copyright holder who authorizes use under this 462 | License of the Program or a work on which the Program is based. The 463 | work thus licensed is called the contributor's "contributor version". 464 | 465 | A contributor's "essential patent claims" are all patent claims 466 | owned or controlled by the contributor, whether already acquired or 467 | hereafter acquired, that would be infringed by some manner, permitted 468 | by this License, of making, using, or selling its contributor version, 469 | but do not include claims that would be infringed only as a 470 | consequence of further modification of the contributor version. For 471 | purposes of this definition, "control" includes the right to grant 472 | patent sublicenses in a manner consistent with the requirements of 473 | this License. 474 | 475 | Each contributor grants you a non-exclusive, worldwide, royalty-free 476 | patent license under the contributor's essential patent claims, to 477 | make, use, sell, offer for sale, import and otherwise run, modify and 478 | propagate the contents of its contributor version. 479 | 480 | In the following three paragraphs, a "patent license" is any express 481 | agreement or commitment, however denominated, not to enforce a patent 482 | (such as an express permission to practice a patent or covenant not to 483 | sue for patent infringement). To "grant" such a patent license to a 484 | party means to make such an agreement or commitment not to enforce a 485 | patent against the party. 486 | 487 | If you convey a covered work, knowingly relying on a patent license, 488 | and the Corresponding Source of the work is not available for anyone 489 | to copy, free of charge and under the terms of this License, through a 490 | publicly available network server or other readily accessible means, 491 | then you must either (1) cause the Corresponding Source to be so 492 | available, or (2) arrange to deprive yourself of the benefit of the 493 | patent license for this particular work, or (3) arrange, in a manner 494 | consistent with the requirements of this License, to extend the patent 495 | license to downstream recipients. "Knowingly relying" means you have 496 | actual knowledge that, but for the patent license, your conveying the 497 | covered work in a country, or your recipient's use of the covered work 498 | in a country, would infringe one or more identifiable patents in that 499 | country that you have reason to believe are valid. 500 | 501 | If, pursuant to or in connection with a single transaction or 502 | arrangement, you convey, or propagate by procuring conveyance of, a 503 | covered work, and grant a patent license to some of the parties 504 | receiving the covered work authorizing them to use, propagate, modify 505 | or convey a specific copy of the covered work, then the patent license 506 | you grant is automatically extended to all recipients of the covered 507 | work and works based on it. 508 | 509 | A patent license is "discriminatory" if it does not include within 510 | the scope of its coverage, prohibits the exercise of, or is 511 | conditioned on the non-exercise of one or more of the rights that are 512 | specifically granted under this License. You may not convey a covered 513 | work if you are a party to an arrangement with a third party that is 514 | in the business of distributing software, under which you make payment 515 | to the third party based on the extent of your activity of conveying 516 | the work, and under which the third party grants, to any of the 517 | parties who would receive the covered work from you, a discriminatory 518 | patent license (a) in connection with copies of the covered work 519 | conveyed by you (or copies made from those copies), or (b) primarily 520 | for and in connection with specific products or compilations that 521 | contain the covered work, unless you entered into that arrangement, 522 | or that patent license was granted, prior to 28 March 2007. 523 | 524 | Nothing in this License shall be construed as excluding or limiting 525 | any implied license or other defenses to infringement that may 526 | otherwise be available to you under applicable patent law. 527 | 528 | 12. No Surrender of Others' Freedom. 529 | 530 | If conditions are imposed on you (whether by court order, agreement or 531 | otherwise) that contradict the conditions of this License, they do not 532 | excuse you from the conditions of this License. If you cannot convey a 533 | covered work so as to satisfy simultaneously your obligations under this 534 | License and any other pertinent obligations, then as a consequence you may 535 | not convey it at all. For example, if you agree to terms that obligate you 536 | to collect a royalty for further conveying from those to whom you convey 537 | the Program, the only way you could satisfy both those terms and this 538 | License would be to refrain entirely from conveying the Program. 539 | 540 | 13. Remote Network Interaction; Use with the GNU General Public License. 541 | 542 | Notwithstanding any other provision of this License, if you modify the 543 | Program, your modified version must prominently offer all users 544 | interacting with it remotely through a computer network (if your version 545 | supports such interaction) an opportunity to receive the Corresponding 546 | Source of your version by providing access to the Corresponding Source 547 | from a network server at no charge, through some standard or customary 548 | means of facilitating copying of software. This Corresponding Source 549 | shall include the Corresponding Source for any work covered by version 3 550 | of the GNU General Public License that is incorporated pursuant to the 551 | following paragraph. 552 | 553 | Notwithstanding any other provision of this License, you have 554 | permission to link or combine any covered work with a work licensed 555 | under version 3 of the GNU General Public License into a single 556 | combined work, and to convey the resulting work. The terms of this 557 | License will continue to apply to the part which is the covered work, 558 | but the work with which it is combined will remain governed by version 559 | 3 of the GNU General Public License. 560 | 561 | 14. Revised Versions of this License. 562 | 563 | The Free Software Foundation may publish revised and/or new versions of 564 | the GNU Affero General Public License from time to time. Such new versions 565 | will be similar in spirit to the present version, but may differ in detail to 566 | address new problems or concerns. 567 | 568 | Each version is given a distinguishing version number. If the 569 | Program specifies that a certain numbered version of the GNU Affero General 570 | Public License "or any later version" applies to it, you have the 571 | option of following the terms and conditions either of that numbered 572 | version or of any later version published by the Free Software 573 | Foundation. If the Program does not specify a version number of the 574 | GNU Affero General Public License, you may choose any version ever published 575 | by the Free Software Foundation. 576 | 577 | If the Program specifies that a proxy can decide which future 578 | versions of the GNU Affero General Public License can be used, that proxy's 579 | public statement of acceptance of a version permanently authorizes you 580 | to choose that version for the Program. 581 | 582 | Later license versions may give you additional or different 583 | permissions. However, no additional obligations are imposed on any 584 | author or copyright holder as a result of your choosing to follow a 585 | later version. 586 | 587 | 15. Disclaimer of Warranty. 588 | 589 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 590 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 591 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 592 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 593 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 594 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 595 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 596 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 597 | 598 | 16. Limitation of Liability. 599 | 600 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 601 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 602 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 603 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 604 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 605 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 606 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 607 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 608 | SUCH DAMAGES. 609 | 610 | 17. Interpretation of Sections 15 and 16. 611 | 612 | If the disclaimer of warranty and limitation of liability provided 613 | above cannot be given local legal effect according to their terms, 614 | reviewing courts shall apply local law that most closely approximates 615 | an absolute waiver of all civil liability in connection with the 616 | Program, unless a warranty or assumption of liability accompanies a 617 | copy of the Program in return for a fee. 618 | 619 | END OF TERMS AND CONDITIONS 620 | 621 | How to Apply These Terms to Your New Programs 622 | 623 | If you develop a new program, and you want it to be of the greatest 624 | possible use to the public, the best way to achieve this is to make it 625 | free software which everyone can redistribute and change under these terms. 626 | 627 | To do so, attach the following notices to the program. It is safest 628 | to attach them to the start of each source file to most effectively 629 | state the exclusion of warranty; and each file should have at least 630 | the "copyright" line and a pointer to where the full notice is found. 631 | 632 | 633 | Copyright (C) 634 | 635 | This program is free software: you can redistribute it and/or modify 636 | it under the terms of the GNU Affero General Public License as published 637 | by the Free Software Foundation, either version 3 of the License, or 638 | (at your option) any later version. 639 | 640 | This program is distributed in the hope that it will be useful, 641 | but WITHOUT ANY WARRANTY; without even the implied warranty of 642 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 643 | GNU Affero General Public License for more details. 644 | 645 | You should have received a copy of the GNU Affero General Public License 646 | along with this program. If not, see . 647 | 648 | Also add information on how to contact you by electronic and paper mail. 649 | 650 | If your software can interact with users remotely through a computer 651 | network, you should also make sure that it provides a way for users to 652 | get its source. For example, if your program is a web application, its 653 | interface could display a "Source" link that leads users to an archive 654 | of the code. There are many ways you could offer source, and different 655 | solutions will be better for different programs; see section 13 for the 656 | specific requirements. 657 | 658 | You should also get your employer (if you work as a programmer) or school, 659 | if any, to sign a "copyright disclaimer" for the program, if necessary. 660 | For more information on this, and how to apply and follow the GNU AGPL, see 661 | . 662 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 |

3 | Jupyter Variable Inspector banner 4 |

5 | 6 | # Jupyter Variable Inspector 7 | 8 | The Variable Inspector is a Jupyter Lab extension designed to help you manage and track variables within your notebook. It displays all your variables in one convenient location, allowing you to see their names, values, types, shapes, and sizes in real-time. This feature makes it easier to work without the need to manually print or check your variables. **It is for Python only.**. 9 | 10 | Install the extension using `pip` by following the instructions below. It’s also available in our desktop app, [MLJAR Studio](https://mljar.com), which is designed to make Python easier for beginners. 11 | 12 | ## Features 13 | 14 | ### Display variables 15 | 16 | Explore all available variables in the current notebook as a list. 17 | 18 | Jupyter Variable Inspector displays variables 19 | 20 | 21 | ### Display DataFrames 22 | 23 | You can preview the DataFrame values as an interactive table. 24 | 25 | Jupyter Variable Inspector display DataFrame 26 | 27 | 28 | ### Display DataFrames with updates 29 | 30 | The preview of DataFrame will be automatically refreshed when you change it in the Python code. 31 | 32 | Jupyter Variable Inspector update data 33 | 34 | 35 | ### Customize displayed columns 36 | 37 | You can select which properties of the variables you'd like to display: 38 | 39 | ![cols](https://github.com/user-attachments/assets/d282fdac-491d-4890-af07-fce5dbdaa27a) 40 | 41 | ### Automatic or manual refresh 42 | 43 | The list of variables will automatically update whenever you execute a cell. However, you can choose the Manual Refresh option to update the list at your convenience. 44 | 45 | ![image](https://github.com/user-attachments/assets/281eec42-a227-434d-bb36-028a10e8338c) 46 | 47 | ### Dark theme 48 | 49 | If you prefer a darker look, a Dark Theme is also available! 50 | 51 | ![image](https://github.com/user-attachments/assets/e9b4356a-68dc-4ee9-84bf-de4944466301) 52 | 53 | ## Variable Inspector requirements 54 | 55 | - JupyterLab >= 4.0.0 56 | 57 | ## Install extension 58 | 59 | To install the extension, execute: 60 | 61 | ```bash 62 | pip install variable_inspector 63 | ``` 64 | 65 | ## Uninstall extension 66 | 67 | To remove the extension, execute: 68 | 69 | ```bash 70 | pip uninstall variable_inspector 71 | ``` 72 | 73 | ## Contributing 74 | 75 | ### Development install 76 | 77 | Note: You will need NodeJS to build the extension package. 78 | 79 | The `jlpm` command is JupyterLab's pinned version of 80 | [yarn](https://yarnpkg.com/) that is installed with JupyterLab. You may use 81 | `yarn` or `npm` in lieu of `jlpm` below. 82 | 83 | ```bash 84 | # Clone the repo to your local environment 85 | # Change directory to the variable_inspector directory 86 | # Install package in development mode 87 | pip install -e "." 88 | # Link your development version of the extension with JupyterLab 89 | jupyter labextension develop . --overwrite 90 | # Rebuild extension Typescript source after making changes 91 | jlpm build 92 | ``` 93 | 94 | You can watch the source directory and run JupyterLab at the same time in different terminals to watch for changes in the extension's source and automatically rebuild the extension. 95 | 96 | ```bash 97 | # Watch the source directory in one terminal, automatically rebuilding when needed 98 | jlpm watch 99 | # Run JupyterLab in another terminal 100 | jupyter lab 101 | ``` 102 | 103 | With the watch command running, every saved change will immediately be built locally and available in your running JupyterLab. Refresh JupyterLab to load the change in your browser (you may need to wait several seconds for the extension to be rebuilt). 104 | 105 | By default, the `jlpm build` command generates the source maps for this extension to make it easier to debug using the browser dev tools. To also generate source maps for the JupyterLab core extensions, you can run the following command: 106 | 107 | ```bash 108 | jupyter lab build --minimize=False 109 | ``` 110 | 111 | ### Development uninstall 112 | 113 | ```bash 114 | pip uninstall variable_inspector 115 | ``` 116 | 117 | In development mode, you will also need to remove the symlink created by `jupyter labextension develop` 118 | command. To find its location, you can run `jupyter labextension list` to figure out where the `labextensions` 119 | folder is located. Then you can remove the symlink named `variable-inspector` within that folder. 120 | 121 | ### Packaging the extension 122 | 123 | See [RELEASE](RELEASE.md) 124 | -------------------------------------------------------------------------------- /RELEASE.md: -------------------------------------------------------------------------------- 1 | # Making a new release of variable_inspector 2 | 3 | The extension can be published to `PyPI` and `npm` manually or using the [Jupyter Releaser](https://github.com/jupyter-server/jupyter_releaser). 4 | 5 | ## Manual release 6 | 7 | ### Python package 8 | 9 | This extension can be distributed as Python packages. All of the Python 10 | packaging instructions are in the `pyproject.toml` file to wrap your extension in a 11 | Python package. Before generating a package, you first need to install some tools: 12 | 13 | ```bash 14 | pip install build twine hatch 15 | ``` 16 | 17 | Bump the version using `hatch`. By default this will create a tag. 18 | See the docs on [hatch-nodejs-version](https://github.com/agoose77/hatch-nodejs-version#semver) for details. 19 | 20 | ```bash 21 | hatch version 22 | ``` 23 | 24 | Make sure to clean up all the development files before building the package: 25 | 26 | ```bash 27 | jlpm clean:all 28 | ``` 29 | 30 | You could also clean up the local git repository: 31 | 32 | ```bash 33 | git clean -dfX 34 | ``` 35 | 36 | To create a Python source package (`.tar.gz`) and the binary package (`.whl`) in the `dist/` directory, do: 37 | 38 | ```bash 39 | python -m build 40 | ``` 41 | 42 | > `python setup.py sdist bdist_wheel` is deprecated and will not work for this package. 43 | 44 | Then to upload the package to PyPI, do: 45 | 46 | ```bash 47 | twine upload dist/* 48 | ``` 49 | 50 | ### NPM package 51 | 52 | To publish the frontend part of the extension as a NPM package, do: 53 | 54 | ```bash 55 | npm login 56 | npm publish --access public 57 | ``` 58 | 59 | ## Automated releases with the Jupyter Releaser 60 | 61 | The extension repository should already be compatible with the Jupyter Releaser. But 62 | the GitHub repository and the package managers need to be properly set up. Please 63 | follow the instructions of the Jupyter Releaser [checklist](https://jupyter-releaser.readthedocs.io/en/latest/how_to_guides/convert_repo_from_repo.html). 64 | 65 | Here is a summary of the steps to cut a new release: 66 | 67 | - Go to the Actions panel 68 | - Run the "Step 1: Prep Release" workflow 69 | - Check the draft changelog 70 | - Run the "Step 2: Publish Release" workflow 71 | 72 | > [!NOTE] 73 | > Check out the [workflow documentation](https://jupyter-releaser.readthedocs.io/en/latest/get_started/making_release_from_repo.html) 74 | > for more information. 75 | 76 | ## Publishing to `conda-forge` 77 | 78 | If the package is not on conda forge yet, check the documentation to learn how to add it: https://conda-forge.org/docs/maintainer/adding_pkgs.html 79 | 80 | Otherwise a bot should pick up the new version publish to PyPI, and open a new PR on the feedstock repository automatically. 81 | -------------------------------------------------------------------------------- /binder/environment.yml: -------------------------------------------------------------------------------- 1 | # a mybinder.org-ready environment for demoing variable_inspector 2 | # this environment may also be used locally on Linux/MacOS/Windows, e.g. 3 | # 4 | # conda env update --file binder/environment.yml 5 | # conda activate variable-inspector-demo 6 | # 7 | name: variable-inspector-demo 8 | 9 | channels: 10 | - conda-forge 11 | 12 | dependencies: 13 | # runtime dependencies 14 | - python >=3.10,<3.11.0a0 15 | - jupyterlab >=4.0.0,<5 16 | # labextension build dependencies 17 | - nodejs >=18,<19 18 | - pip 19 | - wheel 20 | # additional packages for demos 21 | # - ipywidgets 22 | -------------------------------------------------------------------------------- /binder/postBuild: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | """ perform a development install of variable_inspector 3 | 4 | On Binder, this will run _after_ the environment has been fully created from 5 | the environment.yml in this directory. 6 | 7 | This script should also run locally on Linux/MacOS/Windows: 8 | 9 | python3 binder/postBuild 10 | """ 11 | import subprocess 12 | import sys 13 | from pathlib import Path 14 | 15 | 16 | ROOT = Path.cwd() 17 | 18 | def _(*args, **kwargs): 19 | """ Run a command, echoing the args 20 | 21 | fails hard if something goes wrong 22 | """ 23 | print("\n\t", " ".join(args), "\n") 24 | return_code = subprocess.call(args, **kwargs) 25 | if return_code != 0: 26 | print("\nERROR", return_code, " ".join(args)) 27 | sys.exit(return_code) 28 | 29 | # verify the environment is self-consistent before even starting 30 | _(sys.executable, "-m", "pip", "check") 31 | 32 | # install the labextension 33 | _(sys.executable, "-m", "pip", "install", "-e", ".") 34 | _(sys.executable, "-m", "jupyter", "labextension", "develop", "--overwrite", ".") 35 | 36 | # verify the environment the extension didn't break anything 37 | _(sys.executable, "-m", "pip", "check") 38 | 39 | # list the extensions 40 | _("jupyter", "server", "extension", "list") 41 | 42 | # initially list installed extensions to determine if there are any surprises 43 | _("jupyter", "labextension", "list") 44 | 45 | 46 | print("JupyterLab with variable_inspector is ready to run with:\n") 47 | print("\tjupyter lab\n") 48 | -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | jlpm run build 4 | 5 | python -m build 6 | 7 | cp dist/variable_inspector-1.0.1-py3-none-any.whl ../studio/env_installer/extras/ 8 | -------------------------------------------------------------------------------- /install.json: -------------------------------------------------------------------------------- 1 | { 2 | "packageManager": "python", 3 | "packageName": "variable_inspector", 4 | "uninstallInstructions": "Use your Python package manager (pip, conda, etc.) to uninstall the package variable_inspector" 5 | } 6 | -------------------------------------------------------------------------------- /media/jupyter-variable-inspector-banner.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mljar/variable-inspector/f585c4299d13ce8b39713d51a5ce1ebec0f2926a/media/jupyter-variable-inspector-banner.jpg -------------------------------------------------------------------------------- /media/jupyter-variable-inspector-display-data-frame.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mljar/variable-inspector/f585c4299d13ce8b39713d51a5ce1ebec0f2926a/media/jupyter-variable-inspector-display-data-frame.gif -------------------------------------------------------------------------------- /media/jupyter-variable-inspector-update-data.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mljar/variable-inspector/f585c4299d13ce8b39713d51a5ce1ebec0f2926a/media/jupyter-variable-inspector-update-data.gif -------------------------------------------------------------------------------- /media/jupyter-variable-inspector.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mljar/variable-inspector/f585c4299d13ce8b39713d51a5ce1ebec0f2926a/media/jupyter-variable-inspector.gif -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "variable-inspector", 3 | "version": "1.0.1", 4 | "description": "Variable inspector for jupyter lab.", 5 | "keywords": [ 6 | "jupyter", 7 | "jupyterlab", 8 | "jupyterlab-extension" 9 | ], 10 | "homepage": "https://github.com/mljar/variable-inspector.git", 11 | "bugs": { 12 | "url": "https://github.com/mljar/variable-inspector.git/issues" 13 | }, 14 | "license": "SEE LICENSE IN LICENSE", 15 | "author": { 16 | "name": "MLJAR", 17 | "email": "contact@mljar.com" 18 | }, 19 | "files": [ 20 | "lib/**/*.{d.ts,eot,gif,html,jpg,js,js.map,json,png,svg,woff2,ttf}", 21 | "style/**/*.{css,js,eot,gif,html,jpg,json,png,svg,woff2,ttf}", 22 | "src/**/*.{ts,tsx}", 23 | "schema/*.json" 24 | ], 25 | "main": "lib/index.js", 26 | "types": "lib/index.d.ts", 27 | "style": "style/index.css", 28 | "repository": { 29 | "type": "git", 30 | "url": "https://github.com/mljar/variable-inspector.git.git" 31 | }, 32 | "scripts": { 33 | "build": "jlpm build:lib && jlpm build:labextension:dev", 34 | "build:prod": "jlpm clean && jlpm build:lib:prod && jlpm build:labextension", 35 | "build:labextension": "jupyter labextension build .", 36 | "build:labextension:dev": "jupyter labextension build --development True .", 37 | "build:lib": "tsc --sourceMap", 38 | "build:lib:prod": "tsc", 39 | "clean": "jlpm clean:lib", 40 | "clean:lib": "rimraf lib tsconfig.tsbuildinfo", 41 | "clean:lintcache": "rimraf .eslintcache .stylelintcache", 42 | "clean:labextension": "rimraf variable_inspector/labextension variable_inspector/_version.py", 43 | "clean:all": "jlpm clean:lib && jlpm clean:labextension && jlpm clean:lintcache", 44 | "eslint": "jlpm eslint:check --fix", 45 | "eslint:check": "eslint . --cache --ext .ts,.tsx", 46 | "install:extension": "jlpm build", 47 | "lint": "jlpm stylelint && jlpm prettier && jlpm eslint", 48 | "lint:check": "jlpm stylelint:check && jlpm prettier:check && jlpm eslint:check", 49 | "prettier": "jlpm prettier:base --write --list-different", 50 | "prettier:base": "prettier \"**/*{.ts,.tsx,.js,.jsx,.css,.json,.md}\"", 51 | "prettier:check": "jlpm prettier:base --check", 52 | "stylelint": "jlpm stylelint:check --fix", 53 | "stylelint:check": "stylelint --cache \"style/**/*.css\"", 54 | "watch": "run-p watch:src watch:labextension", 55 | "watch:src": "tsc -w --sourceMap", 56 | "watch:labextension": "jupyter labextension watch ." 57 | }, 58 | "dependencies": { 59 | "@jupyterlab/application": "^4.0.0", 60 | "@jupyterlab/notebook": "^4.0.0", 61 | "@jupyterlab/settingregistry": "^4.0.0", 62 | "react": "^19.0.0", 63 | "react-dom": "^19.0.0", 64 | "react-virtualized": "^9.22.6" 65 | }, 66 | "devDependencies": { 67 | "@jupyterlab/builder": "^4.0.0", 68 | "@types/json-schema": "^7.0.11", 69 | "@types/react": "^18.0.26", 70 | "@types/react-addons-linked-state-mixin": "^0.14.22", 71 | "@types/react-dom": "^19.0.3", 72 | "@types/react-virtualized": "^9.22.0", 73 | "@typescript-eslint/eslint-plugin": "^6.1.0", 74 | "@typescript-eslint/parser": "^6.1.0", 75 | "css-loader": "^6.7.1", 76 | "eslint": "^8.36.0", 77 | "eslint-config-prettier": "^8.8.0", 78 | "eslint-plugin-prettier": "^5.0.0", 79 | "npm-run-all2": "^7.0.1", 80 | "prettier": "^3.0.0", 81 | "rimraf": "^5.0.1", 82 | "source-map-loader": "^1.0.2", 83 | "style-loader": "^3.3.1", 84 | "stylelint": "^15.10.1", 85 | "stylelint-config-recommended": "^13.0.0", 86 | "stylelint-config-standard": "^34.0.0", 87 | "stylelint-csstree-validator": "^3.0.0", 88 | "stylelint-prettier": "^4.0.0", 89 | "typescript": "~5.0.2", 90 | "webpack": "^5.97.1", 91 | "yjs": "^13.5.0" 92 | }, 93 | "sideEffects": [ 94 | "style/*.css", 95 | "style/index.js" 96 | ], 97 | "styleModule": "style/index.js", 98 | "publishConfig": { 99 | "access": "public" 100 | }, 101 | "jupyterlab": { 102 | "extension": true, 103 | "outputDir": "variable_inspector/labextension", 104 | "schemaDir": "schema" 105 | }, 106 | "eslintIgnore": [ 107 | "node_modules", 108 | "dist", 109 | "coverage", 110 | "**/*.d.ts" 111 | ], 112 | "eslintConfig": { 113 | "extends": [ 114 | "eslint:recommended", 115 | "plugin:@typescript-eslint/eslint-recommended", 116 | "plugin:@typescript-eslint/recommended", 117 | "plugin:prettier/recommended" 118 | ], 119 | "parser": "@typescript-eslint/parser", 120 | "parserOptions": { 121 | "project": "tsconfig.json", 122 | "sourceType": "module" 123 | }, 124 | "plugins": [ 125 | "@typescript-eslint" 126 | ], 127 | "rules": { 128 | "@typescript-eslint/naming-convention": [ 129 | "error", 130 | { 131 | "selector": "interface", 132 | "format": [ 133 | "PascalCase" 134 | ], 135 | "custom": { 136 | "regex": "^I[A-Z]", 137 | "match": true 138 | } 139 | } 140 | ], 141 | "@typescript-eslint/no-unused-vars": [ 142 | "warn", 143 | { 144 | "args": "none" 145 | } 146 | ], 147 | "@typescript-eslint/no-explicit-any": "off", 148 | "@typescript-eslint/no-namespace": "off", 149 | "@typescript-eslint/no-use-before-define": "off", 150 | "@typescript-eslint/quotes": [ 151 | "error", 152 | "single", 153 | { 154 | "avoidEscape": true, 155 | "allowTemplateLiterals": false 156 | } 157 | ], 158 | "curly": [ 159 | "error", 160 | "all" 161 | ], 162 | "eqeqeq": "error", 163 | "prefer-arrow-callback": "error" 164 | } 165 | }, 166 | "prettier": { 167 | "singleQuote": true, 168 | "trailingComma": "none", 169 | "arrowParens": "avoid", 170 | "endOfLine": "auto", 171 | "overrides": [ 172 | { 173 | "files": "package.json", 174 | "options": { 175 | "tabWidth": 4 176 | } 177 | } 178 | ] 179 | }, 180 | "stylelint": { 181 | "extends": [ 182 | "stylelint-config-recommended", 183 | "stylelint-config-standard", 184 | "stylelint-prettier/recommended" 185 | ], 186 | "plugins": [ 187 | "stylelint-csstree-validator" 188 | ], 189 | "rules": { 190 | "csstree/validator": true, 191 | "property-no-vendor-prefix": null, 192 | "selector-class-pattern": "^([a-z][A-z\\d]*)(-[A-z\\d]+)*$", 193 | "selector-no-vendor-prefix": null, 194 | "value-no-vendor-prefix": null 195 | } 196 | } 197 | } 198 | -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | [build-system] 2 | requires = ["hatchling>=1.5.0", "jupyterlab>=4.0.0,<5", "hatch-nodejs-version>=0.3.2"] 3 | build-backend = "hatchling.build" 4 | 5 | [project] 6 | name = "variable_inspector" 7 | readme = "README.md" 8 | license = { file = "LICENSE" } 9 | requires-python = ">=3.8" 10 | classifiers = [ 11 | "Framework :: Jupyter", 12 | "Framework :: Jupyter :: JupyterLab", 13 | "Framework :: Jupyter :: JupyterLab :: 4", 14 | "Framework :: Jupyter :: JupyterLab :: Extensions", 15 | "Framework :: Jupyter :: JupyterLab :: Extensions :: Prebuilt", 16 | "License :: OSI Approved :: BSD License", 17 | "Programming Language :: Python", 18 | "Programming Language :: Python :: 3", 19 | "Programming Language :: Python :: 3.9", 20 | "Programming Language :: Python :: 3.10", 21 | "Programming Language :: Python :: 3.11", 22 | "Programming Language :: Python :: 3.12", 23 | "Programming Language :: Python :: 3.13", 24 | ] 25 | dependencies = [ 26 | ] 27 | dynamic = ["version", "description", "authors", "urls", "keywords"] 28 | 29 | [tool.hatch.version] 30 | source = "nodejs" 31 | 32 | [tool.hatch.metadata.hooks.nodejs] 33 | fields = ["description", "authors", "urls", "keywords"] 34 | 35 | [tool.hatch.build.targets.sdist] 36 | artifacts = ["variable_inspector/labextension"] 37 | exclude = [".github", "binder"] 38 | 39 | [tool.hatch.build.targets.wheel.shared-data] 40 | "variable_inspector/labextension" = "share/jupyter/labextensions/variable-inspector" 41 | "install.json" = "share/jupyter/labextensions/variable-inspector/install.json" 42 | 43 | [tool.hatch.build.hooks.version] 44 | path = "variable_inspector/_version.py" 45 | 46 | [tool.hatch.build.hooks.jupyter-builder] 47 | dependencies = ["hatch-jupyter-builder>=0.5"] 48 | build-function = "hatch_jupyter_builder.npm_builder" 49 | ensured-targets = [ 50 | "variable_inspector/labextension/static/style.js", 51 | "variable_inspector/labextension/package.json", 52 | ] 53 | skip-if-exists = ["variable_inspector/labextension/static/style.js"] 54 | 55 | [tool.hatch.build.hooks.jupyter-builder.build-kwargs] 56 | build_cmd = "build:prod" 57 | npm = ["jlpm"] 58 | 59 | [tool.hatch.build.hooks.jupyter-builder.editable-build-kwargs] 60 | build_cmd = "install:extension" 61 | npm = ["jlpm"] 62 | source_dir = "src" 63 | build_dir = "variable_inspector/labextension" 64 | 65 | [tool.jupyter-releaser.options] 66 | version_cmd = "hatch version" 67 | 68 | [tool.jupyter-releaser.hooks] 69 | before-build-npm = [ 70 | "python -m pip install 'jupyterlab>=4.0.0,<5'", 71 | "jlpm", 72 | "jlpm build:prod" 73 | ] 74 | before-build-python = ["jlpm clean:all"] 75 | 76 | [tool.check-wheel-contents] 77 | ignore = ["W002"] 78 | -------------------------------------------------------------------------------- /schema/plugin.json: -------------------------------------------------------------------------------- 1 | { 2 | "jupyter.lab.shortcuts": [], 3 | "title": "variable-inspector", 4 | "description": "variable-inspector settings.", 5 | "type": "object", 6 | "properties": { 7 | "variableInspectorAutoRefresh": { 8 | "type": "boolean", 9 | "title": "variableInspectorAutoRefresh", 10 | "description": "Enable Auto Refresh", 11 | "default": true 12 | }, 13 | "variableInspectorShowType": { 14 | "type": "boolean", 15 | "title": "variableInspectorShowType", 16 | "description": "Show Type Column", 17 | "default": true 18 | }, 19 | "variableInspectorShowShape": { 20 | "type": "boolean", 21 | "title": "variableInspectorShowShape", 22 | "description": "Show Shape Column", 23 | "default": false 24 | }, 25 | "variableInspectorShowSize": { 26 | "type": "boolean", 27 | "title": "variableInspectorShowSize", 28 | "description": "Show Size Column", 29 | "default": false 30 | } 31 | }, 32 | "additionalProperties": false 33 | } 34 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | __import__("setuptools").setup() 2 | -------------------------------------------------------------------------------- /src/components/paginationControls.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { skipLeftIcon } from '../icons/skipLeftIcon'; 3 | import { smallSkipLeftIcon } from '../icons/smallSkipLeftIcon'; 4 | import { smallSkipRightIcon } from '../icons/smallSkipRightIcon'; 5 | import { skipRightIcon } from '../icons/skipRightIcon'; 6 | // import { gridScanIcon } from '../icons/gridScanIcon'; 7 | 8 | interface PaginationControlsProps { 9 | rowsCount: number; 10 | colsCount: number; 11 | rowInput: string; 12 | setRowInput: (value: string) => void; 13 | currentRow: number; 14 | setCurrentRow: (value: number) => void; 15 | columnInput: string; 16 | setColumnInput: (value: string) => void; 17 | currentColumn: number; 18 | setCurrentColumn: (value: number) => void; 19 | cellRowInput: string; 20 | setCellRowInput: (value: string) => void; 21 | cellColumnInput: string; 22 | setCellColumnInput: (value: string) => void; 23 | handleGotoCell: () => void; 24 | handlePrevRowPage: (value: string) => void; 25 | handleNextRowPage: (value: string) => void; 26 | handlePrevColumnPage: (value: string) => void; 27 | handleNextColumnPage: (value: string) => void; 28 | } 29 | 30 | export const PaginationControls: React.FC = ({ 31 | rowsCount, 32 | colsCount, 33 | rowInput, 34 | setRowInput, 35 | currentRow, 36 | setCurrentRow, 37 | columnInput, 38 | setColumnInput, 39 | currentColumn, 40 | setCurrentColumn, 41 | cellRowInput, 42 | setCellRowInput, 43 | cellColumnInput, 44 | setCellColumnInput, 45 | handleGotoCell, 46 | handlePrevRowPage, 47 | handleNextRowPage, 48 | handlePrevColumnPage, 49 | handleNextColumnPage 50 | }) => { 51 | return ( 52 |
53 |
54 |
55 | Rows from 56 | 63 | 70 | setRowInput(e.target.value)} 78 | onKeyDown={e => { 79 | if (e.key === 'Enter') { 80 | const newPage = parseInt(rowInput, 10); 81 | if (!isNaN(newPage) && newPage >= 0 && newPage <= rowsCount) { 82 | setCurrentRow(newPage); 83 | setRowInput(newPage.toString()); 84 | } 85 | } 86 | }} 87 | onBlur={() => { 88 | const newPage = parseInt(rowInput, 10); 89 | if (isNaN(newPage) || newPage < 0 || newPage > rowsCount) { 90 | setRowInput(currentRow.toString()); 91 | } else { 92 | setCurrentRow(newPage); 93 | } 94 | }} 95 | /> 96 | to 97 | 98 | {parseInt(rowInput) + 99 >= rowsCount 99 | ? rowsCount - 1 100 | : parseInt(rowInput) + 99} 101 | 102 | 109 | 116 | 117 | Total {rowsCount} rows 118 | 119 |
120 |
121 | Columns from 122 | 129 | 136 | setColumnInput(e.target.value)} 144 | onKeyDown={e => { 145 | if (e.key === 'Enter') { 146 | const newPage = parseInt(columnInput, 10); 147 | if (!isNaN(newPage) && newPage >= 0 && newPage <= colsCount) { 148 | setCurrentColumn(newPage); 149 | setColumnInput(newPage.toString()); 150 | } 151 | } 152 | }} 153 | onBlur={() => { 154 | const newPage = parseInt(columnInput, 10); 155 | if (isNaN(newPage) || newPage < 0 || newPage > colsCount) { 156 | setColumnInput(currentColumn.toString()); 157 | } else { 158 | setCurrentColumn(newPage); 159 | } 160 | }} 161 | /> 162 | to 163 | 164 | {parseInt(columnInput) + 49 >= colsCount 165 | ? colsCount - 1 166 | : parseInt(columnInput) + 49} 167 | 168 | 175 | 182 | 183 | Total {colsCount} columns 184 | 185 |
186 | {/* Goto Cell section */} 187 | {/*
188 | Goto cell: 189 | setCellRowInput(e.target.value)} 195 | onKeyDown={e => { 196 | if (e.key === 'Enter') { 197 | const newVal = parseInt(cellRowInput, 10); 198 | if (isNaN(newVal) || newVal < 0) { 199 | setCellRowInput('0'); 200 | } else { 201 | handleGotoCell(); 202 | } 203 | } 204 | }} 205 | onBlur={() => { 206 | const newVal = parseInt(cellRowInput, 10); 207 | if (isNaN(newVal) || newVal < 0) { 208 | setCellRowInput('0'); 209 | } 210 | }} 211 | /> 212 | setCellColumnInput(e.target.value)} 218 | onKeyDown={e => { 219 | if (e.key === 'Enter') { 220 | const newVal = parseInt(cellColumnInput, 10); 221 | if (isNaN(newVal) || newVal < 0) { 222 | setCellColumnInput('0'); 223 | } else { 224 | handleGotoCell(); 225 | } 226 | } 227 | }} 228 | onBlur={() => { 229 | const newVal = parseInt(cellColumnInput, 10); 230 | if (isNaN(newVal) || newVal < 0) { 231 | setCellColumnInput('0'); 232 | } 233 | }} 234 | /> 235 | 241 |
*/} 242 |
243 |
244 | ); 245 | }; 246 | -------------------------------------------------------------------------------- /src/components/searchBar.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { useVariableContext } from '../context/notebookVariableContext'; 3 | 4 | export const SearchBar: React.FC = () => { 5 | const { variables, searchTerm, setSearchTerm } = useVariableContext(); 6 | 7 | const handleChange = (e: React.ChangeEvent) => { 8 | setSearchTerm(e.target.value); 9 | }; 10 | return ( 11 | <> 12 | {variables.length !== 0 ? ( 13 |
14 | 21 |
22 | ) : ( 23 | <> 24 | )} 25 | 26 | ); 27 | }; 28 | -------------------------------------------------------------------------------- /src/components/variableInspectorPanel.ts: -------------------------------------------------------------------------------- 1 | import { ILabShell } from '@jupyterlab/application'; 2 | import { VariablePanelWidget } from './variablePanelWidget'; 3 | import { panelIcon } from '../icons/panelIcon'; 4 | import { NotebookPanel } from '@jupyterlab/notebook'; 5 | 6 | export function createEmptyVariableInspectorPanel( 7 | labShell: ILabShell, 8 | variableName: string, 9 | variableType: string, 10 | variableShape: string, 11 | notebookPanel?: NotebookPanel | null 12 | ): void { 13 | const panel = new VariablePanelWidget({ 14 | variableName, 15 | variableType, 16 | variableShape, 17 | notebookPanel 18 | }); 19 | 20 | panel.id = `${variableType}-${variableName}`; 21 | panel.title.label = `${variableType} ${variableName}`; 22 | panel.title.closable = true; 23 | panel.title.icon = panelIcon; 24 | 25 | const existingPanel = Array.from(labShell.widgets('main')).find( 26 | widget => widget.id === panel.id 27 | ); 28 | 29 | if (existingPanel) { 30 | labShell.add(panel, 'main', { mode: 'tab-after', ref: existingPanel.id }); 31 | } else { 32 | labShell.add(panel, 'main', { mode: 'split-right' }); 33 | } 34 | 35 | labShell.activateById(panel.id); 36 | } 37 | -------------------------------------------------------------------------------- /src/components/variableInspectorSidebar.tsx: -------------------------------------------------------------------------------- 1 | // src/components/variableInspectorSidebarWidget.tsx 2 | import React from 'react'; 3 | import { ReactWidget } from '@jupyterlab/ui-components'; 4 | import { Message } from '@lumino/messaging'; 5 | import { pluginIcon } from '../icons/pluginIcon'; 6 | import { NotebookWatcher } from '../watchers/notebookWatcher'; 7 | import { CommandRegistry } from '@lumino/commands'; 8 | import { IStateDB } from '@jupyterlab/statedb'; 9 | 10 | import { NotebookPanelContextProvider } from '../context/notebookPanelContext'; 11 | import { NotebookKernelContextProvider } from '../context/notebookKernelContext'; 12 | import { VariableContextProvider } from '../context/notebookVariableContext'; 13 | import { VariableListComponent } from './variableListComponent'; 14 | import { 15 | PluginVisibilityContextValue, 16 | PluginVisibilityContext 17 | } from '../context/pluginVisibilityContext'; 18 | import { ILabShell } from '@jupyterlab/application'; 19 | import { ISettingRegistry } from '@jupyterlab/settingregistry'; 20 | import { CodeExecutionContextProvider } from '../context/codeExecutionContext'; 21 | 22 | export class VariableInspectorSidebarWidget extends ReactWidget { 23 | private notebookWatcher: NotebookWatcher; 24 | private commands: CommandRegistry; 25 | private isOpen = false; 26 | private labShell: ILabShell; 27 | private settingRegistry: ISettingRegistry | null = null; 28 | private _stateDB: IStateDB; 29 | 30 | constructor( 31 | notebookWatcher: NotebookWatcher, 32 | commands: CommandRegistry, 33 | labShell: ILabShell, 34 | settingRegistry: ISettingRegistry | null, 35 | stateDB: IStateDB 36 | ) { 37 | super(); 38 | this.notebookWatcher = notebookWatcher; 39 | this.commands = commands; 40 | this.id = 'mljar-variable-inspector::mljar-left-sidebar'; 41 | this.title.icon = pluginIcon; 42 | this.title.caption = 'Variable Inspector'; 43 | this.addClass('mljar-variable-inspector-sidebar-widget'); 44 | this.labShell = labShell; 45 | this.settingRegistry = settingRegistry; 46 | this._stateDB = stateDB; 47 | } 48 | 49 | protected onAfterShow(msg: Message): void { 50 | super.onAfterShow(msg); 51 | this.isOpen = true; 52 | this.update(); 53 | } 54 | 55 | protected onAfterHide(msg: Message): void { 56 | super.onAfterHide(msg); 57 | this.isOpen = false; 58 | this.update(); 59 | } 60 | 61 | render(): JSX.Element { 62 | const contextValue: PluginVisibilityContextValue = { 63 | isPluginOpen: this.isOpen, 64 | setPluginOpen: open => { 65 | this.isOpen = open; 66 | this.update(); 67 | } 68 | }; 69 | 70 | return ( 71 |
72 | 73 | 74 | 77 | 81 | 84 | 89 | 90 | 91 | 92 | 93 | 94 |
95 | ); 96 | } 97 | } 98 | 99 | export function createVariableInspectorSidebar( 100 | notebookWatcher: NotebookWatcher, 101 | commands: CommandRegistry, 102 | labShell: ILabShell, 103 | settingRegistry: ISettingRegistry | null, 104 | stateDB: IStateDB 105 | ): VariableInspectorSidebarWidget { 106 | return new VariableInspectorSidebarWidget( 107 | notebookWatcher, 108 | commands, 109 | labShell, 110 | settingRegistry, 111 | stateDB 112 | ); 113 | } 114 | -------------------------------------------------------------------------------- /src/components/variableItem.tsx: -------------------------------------------------------------------------------- 1 | import React, { useState } from 'react'; 2 | import { detailIcon } from '../icons/detailIcon'; 3 | import { CommandRegistry } from '@lumino/commands'; 4 | import { executeMatrixContent } from '../utils/executeGetMatrix'; 5 | import { useNotebookPanelContext } from '../context/notebookPanelContext'; 6 | import { allowedTypes } from '../utils/allowedTypes'; 7 | import { ILabShell } from '@jupyterlab/application'; 8 | import { createEmptyVariableInspectorPanel } from '../components/variableInspectorPanel'; 9 | 10 | interface VariableInfo { 11 | name: string; 12 | type: string; 13 | shape: string; 14 | dimension: number; 15 | size: number; 16 | value: string; 17 | } 18 | 19 | interface VariableItemProps { 20 | vrb: VariableInfo; 21 | commands: CommandRegistry; 22 | labShell: ILabShell; 23 | showType: boolean; 24 | showShape: boolean; 25 | showSize: boolean; 26 | } 27 | 28 | export const VariableItem: React.FC = ({ 29 | vrb, 30 | commands, 31 | labShell, 32 | showType, 33 | showShape, 34 | showSize 35 | }) => { 36 | const notebookPanel = useNotebookPanelContext(); 37 | const [loading, setLoading] = useState(false); 38 | 39 | const handleButtonClick = async ( 40 | variableName: string, 41 | variableType: string, 42 | variableShape: string 43 | ) => { 44 | if (notebookPanel) { 45 | try { 46 | const result = await executeMatrixContent( 47 | variableName, 48 | 0, 49 | 100, 50 | 0, 51 | 100, 52 | notebookPanel 53 | ); 54 | const variableData = result.content; 55 | let isOpen = false; 56 | for (const widget of labShell.widgets('main')) { 57 | if (widget.id === `${variableType}-${variableName}`) { 58 | isOpen = true; 59 | } 60 | } 61 | if (variableData && !isOpen) { 62 | setLoading(true); 63 | createEmptyVariableInspectorPanel( 64 | labShell, 65 | variableName, 66 | variableType, 67 | variableShape, 68 | notebookPanel 69 | ); 70 | } 71 | } catch (err) { 72 | console.error('unknown error', err); 73 | } finally { 74 | setLoading(false); 75 | } 76 | } 77 | }; 78 | 79 | return ( 80 |
  • 83 | {vrb.name} 84 | {showType && {vrb.type}} 85 | {showShape && ( 86 | 87 | {vrb.shape !== 'None' ? vrb.shape : ''} 88 | 89 | )} 90 | {showSize && ( 91 | 92 | {vrb.size} 93 | 94 | )} 95 | {allowedTypes.includes(vrb.type) && vrb.dimension <= 2 ? ( 96 | vrb.dimension === 1 && vrb.type === 'list' ? ( 97 | 104 | ) : ( 105 | 117 | ) 118 | ) : vrb.type === 'dict' ? ( 119 | 123 | {vrb.value} 124 | 125 | ) : ( 126 | 130 | {vrb.value} 131 | 132 | )} 133 |
  • 134 | ); 135 | }; 136 | -------------------------------------------------------------------------------- /src/components/variableList.tsx: -------------------------------------------------------------------------------- 1 | import React, { useEffect, useState } from 'react'; 2 | import { useVariableContext } from '../context/notebookVariableContext'; 3 | import { VariableItem } from './variableItem'; 4 | import { CommandRegistry } from '@lumino/commands'; 5 | import { ILabShell } from '@jupyterlab/application'; 6 | import { ISettingRegistry } from '@jupyterlab/settingregistry'; 7 | 8 | import { 9 | VARIABLE_INSPECTOR_ID, 10 | showTypeProperty, 11 | showShapeProperty, 12 | showSizeProperty 13 | } from '../index'; 14 | 15 | interface VariableListProps { 16 | commands: CommandRegistry; 17 | labShell: ILabShell; 18 | settingRegistry: ISettingRegistry | null; 19 | } 20 | 21 | export const VariableList: React.FC = ({ 22 | commands, 23 | labShell, 24 | settingRegistry 25 | }) => { 26 | const { variables, searchTerm, loading } = useVariableContext(); 27 | 28 | const filteredVariables = variables.filter(variable => 29 | variable.name.toLowerCase().includes(searchTerm.toLowerCase()) 30 | ); 31 | 32 | const [showType, setShowType] = useState(false); 33 | const [showShape, setShowShape] = useState(false); 34 | const [showSize, setShowSize] = useState(false); 35 | 36 | const loadPropertiesValues = () => { 37 | if (settingRegistry) { 38 | settingRegistry 39 | .load(VARIABLE_INSPECTOR_ID) 40 | .then(settings => { 41 | const updateSettings = (): void => { 42 | const loadShowType = settings.get(showTypeProperty) 43 | .composite as boolean; 44 | setShowType(loadShowType); 45 | const loadShowShape = settings.get(showShapeProperty) 46 | .composite as boolean; 47 | setShowShape(loadShowShape); 48 | const loadShowSize = settings.get(showSizeProperty) 49 | .composite as boolean; 50 | setShowSize(loadShowSize); 51 | }; 52 | updateSettings(); 53 | settings.changed.connect(updateSettings); 54 | }) 55 | .catch(reason => { 56 | console.error( 57 | 'Failed to load settings for Variable Inspector', 58 | reason 59 | ); 60 | }); 61 | } 62 | }; 63 | 64 | useEffect(() => { 65 | loadPropertiesValues(); 66 | }, []); 67 | 68 | return ( 69 |
    70 | {loading ? ( 71 |
    72 | Loading variables... 73 |
    74 | ) : variables.length === 0 ? ( 75 |
    76 | Sorry, no variables available. 77 |
    78 | ) : ( 79 |
      80 |
    • 81 | Name 82 | {showType && Type} 83 | {showShape && Shape} 84 | {showSize && Size} 85 | Value 86 |
    • 87 | {filteredVariables.map((variable, index) => ( 88 | 104 | ))} 105 |
    106 | )} 107 |
    108 | ); 109 | }; 110 | -------------------------------------------------------------------------------- /src/components/variableListComponent.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { VariableList } from './variableList'; 3 | import { SearchBar } from './searchBar'; 4 | import { RefreshButton } from './variableRefreshButton'; 5 | import { CommandRegistry } from '@lumino/commands'; 6 | import { ILabShell } from '@jupyterlab/application'; 7 | import { SettingsButton } from './variableSettingsButton'; 8 | import { ISettingRegistry } from '@jupyterlab/settingregistry'; 9 | 10 | interface IVariableListComponentProps { 11 | commands: CommandRegistry; 12 | labShell: ILabShell; 13 | settingRegistry: ISettingRegistry | null; 14 | } 15 | 16 | export const VariableListComponent: React.FC = ({ 17 | commands, 18 | labShell, 19 | settingRegistry 20 | }) => { 21 | return ( 22 |
    23 |
    24 |

    Variable Inspector

    25 | 26 | 27 |
    28 |
    29 | 30 | 35 |
    36 |
    37 | ); 38 | }; 39 | -------------------------------------------------------------------------------- /src/components/variablePanel.tsx: -------------------------------------------------------------------------------- 1 | import React, { useEffect, useState, useRef, useCallback } from 'react'; 2 | import { 3 | MultiGrid as RVMultiGrid, 4 | AutoSizer as RVAutoSizer 5 | } from 'react-virtualized'; 6 | import 'react-virtualized/styles.css'; 7 | import { allowedTypes } from '../utils/allowedTypes'; 8 | import { NotebookPanel } from '@jupyterlab/notebook'; 9 | import { executeMatrixContent } from '../utils/executeGetMatrix'; 10 | import { useVariableRefeshContext } from '../context/variableRefershContext'; 11 | import { withIgnoredPanelKernelUpdates } from '../utils/kernelOperationNotifier'; 12 | import { useThemeContext } from '../context/themeContext'; 13 | import { transformMatrixData } from '../utils/utils'; 14 | import { PaginationControls } from './paginationControls'; 15 | 16 | interface IVariablePanelProps { 17 | variableName: string; 18 | initVariableType: string; 19 | initVariableShape: string; 20 | notebookPanel?: NotebookPanel | null; 21 | } 22 | 23 | const AutoSizer = RVAutoSizer as unknown as React.ComponentType; 24 | const MultiGrid = RVMultiGrid as unknown as React.ComponentType; 25 | 26 | export const VariablePanel: React.FC = ({ 27 | variableName, 28 | initVariableType, 29 | initVariableShape, 30 | notebookPanel 31 | }) => { 32 | const [variableShape, setVariableShape] = useState(initVariableShape); 33 | const [variableType, setVariableType] = useState(initVariableType); 34 | const { isDark } = useThemeContext(); 35 | const maxRowsRange = 100; 36 | const maxColsRange = 50; 37 | const [matrixData, setMatrixData] = useState([]); 38 | const { refreshCount } = useVariableRefeshContext(); 39 | const [currentRow, setCurrentRow] = useState(0); 40 | const [currentColumn, setCurrentColumn] = useState(0); 41 | const [returnedSize, setReturnedSize] = useState([]); 42 | const [rowInput, setRowInput] = useState(currentRow.toString()); 43 | const [columnInput, setColumnInput] = useState(currentColumn.toString()); 44 | const [rowsCount, setRowsCount] = useState(parseDimensions(variableShape)[0]); 45 | const [colsCount, setColsCount] = useState(parseDimensions(variableShape)[1]); 46 | const [autoSizerKey, setAutoSizerKey] = useState(0); 47 | const containerRef = useRef(null); 48 | const [cellRowInput, setCellRowInput] = useState(''); 49 | const [cellColumnInput, setCellColumnInput] = useState(''); 50 | const [gotoCell, setGotoCell] = useState<{ 51 | row: number; 52 | column: number; 53 | } | null>(null); 54 | const [highlightCell, setHighlightCell] = useState<{ 55 | row: number; 56 | column: number; 57 | } | null>(null); 58 | 59 | const fetchMatrixData = useCallback(async () => { 60 | try { 61 | if (!notebookPanel) { 62 | return; 63 | } 64 | 65 | const result = await withIgnoredPanelKernelUpdates(() => 66 | executeMatrixContent( 67 | variableName, 68 | currentColumn, 69 | currentColumn + maxColsRange > colsCount 70 | ? colsCount 71 | : currentColumn + maxColsRange, 72 | currentRow, 73 | currentRow + maxRowsRange > rowsCount 74 | ? rowsCount 75 | : currentRow + maxRowsRange, 76 | 77 | notebookPanel 78 | ) 79 | ); 80 | setVariableShape(result.variableShape); 81 | setVariableType(result.variableType); 82 | setReturnedSize(result.returnedSize); 83 | setMatrixData(result.content); 84 | } catch (error) { 85 | console.error('Error fetching matrix content:', error); 86 | } 87 | }, [ 88 | notebookPanel, 89 | variableName, 90 | currentColumn, 91 | currentRow, 92 | maxColsRange, 93 | maxRowsRange, 94 | withIgnoredPanelKernelUpdates, 95 | executeMatrixContent, 96 | setVariableShape, 97 | setVariableType, 98 | setReturnedSize, 99 | setMatrixData, 100 | variableType, 101 | returnedSize 102 | ]); 103 | 104 | useEffect(() => { 105 | setRowInput(currentRow.toString()); 106 | }, [currentRow]); 107 | 108 | useEffect(() => { 109 | setColumnInput(currentColumn.toString()); 110 | }, [currentColumn]); 111 | 112 | useEffect(() => { 113 | fetchMatrixData(); 114 | const [rows, cols] = parseDimensions(variableShape); 115 | setRowsCount(rows); 116 | setColsCount(cols); 117 | }, [refreshCount]); 118 | 119 | useEffect(() => { 120 | fetchMatrixData(); 121 | }, [currentRow, currentColumn]); 122 | 123 | useEffect(() => { 124 | if (containerRef.current) { 125 | const resizeObserver = new ResizeObserver(entries => { 126 | for (const entry of entries) { 127 | void entry; 128 | setAutoSizerKey(prev => prev + 1); 129 | } 130 | }); 131 | resizeObserver.observe(containerRef.current); 132 | return () => { 133 | resizeObserver.disconnect(); 134 | }; 135 | } 136 | }, []); 137 | 138 | const handlePrevRowPage = (value: string) => { 139 | if (value === 'previous') { 140 | if (currentRow > maxRowsRange - 1) { 141 | setCurrentRow(currentRow - maxRowsRange); 142 | } else { 143 | setCurrentRow(0); 144 | } 145 | } 146 | if (value === 'first') { 147 | setCurrentRow(0); 148 | } 149 | }; 150 | 151 | const handleNextRowPage = (value: string) => { 152 | if (rowsCount > maxRowsRange) { 153 | if (value === 'next') { 154 | if (currentRow + 2 * maxRowsRange < rowsCount) { 155 | setCurrentRow(currentRow + maxRowsRange); 156 | } else { 157 | setCurrentRow(rowsCount - maxRowsRange); 158 | } 159 | } 160 | if (value === 'last') { 161 | setCurrentRow(rowsCount - maxRowsRange); 162 | } 163 | } else { 164 | setCurrentRow(0); 165 | } 166 | }; 167 | 168 | const handlePrevColumnPage = (value: string) => { 169 | if (value === 'previous') { 170 | if (currentColumn > maxColsRange - 1) { 171 | setCurrentColumn(currentColumn - maxColsRange); 172 | } else { 173 | setCurrentColumn(0); 174 | } 175 | } 176 | if (value === 'first') { 177 | setCurrentColumn(0); 178 | } 179 | }; 180 | 181 | const handleNextColumnPage = (value: string) => { 182 | if (colsCount > maxColsRange) { 183 | if (value === 'next') { 184 | if (currentColumn + 2 * maxColsRange < colsCount) { 185 | setCurrentColumn(currentColumn + maxColsRange); 186 | } else { 187 | setCurrentColumn(colsCount - maxColsRange); 188 | } 189 | } 190 | if (value === 'last') { 191 | setCurrentColumn(colsCount - maxColsRange); 192 | } 193 | } else { 194 | setCurrentColumn(0); 195 | } 196 | }; 197 | 198 | function parseDimensions(input: string): [number, number] { 199 | const regex2D = /^(-?\d+)\s*x\s*(-?\d+)$/; 200 | const match2D = input.match(regex2D); 201 | if (match2D) { 202 | const a = parseInt(match2D[1], 10); 203 | const b = parseInt(match2D[2], 10); 204 | return [a, b]; 205 | } 206 | const regex1D = /^-?\d+$/; 207 | if (input.match(regex1D)) { 208 | const n = parseInt(input, 10); 209 | return [n, 1]; 210 | } 211 | throw new Error('Wrong format'); 212 | } 213 | 214 | const { data, fixedRowCount, fixedColumnCount } = transformMatrixData( 215 | matrixData, 216 | variableType, 217 | currentRow, 218 | currentColumn 219 | ); 220 | 221 | const rowCount = data.length; 222 | const colCount = data[0]?.length || 0; 223 | 224 | const columnWidths: number[] = []; 225 | for (let col = 0; col < colCount; col++) { 226 | let maxLength = 0; 227 | for (let row = 0; row < rowCount; row++) { 228 | const cell = data[row][col]; 229 | const cellStr = cell !== null ? cell.toString() : ''; 230 | if (cellStr.length > maxLength) { 231 | maxLength = cellStr.length; 232 | } 233 | } 234 | columnWidths[col] = maxLength * 7 + 16; 235 | } 236 | 237 | const cellRenderer = ({ 238 | columnIndex, 239 | key, 240 | rowIndex, 241 | style 242 | }: { 243 | columnIndex: number; 244 | key: string; 245 | rowIndex: number; 246 | style: React.CSSProperties; 247 | }) => { 248 | const cellData = data[rowIndex][columnIndex]; 249 | let cellStyle: React.CSSProperties = { 250 | ...style, 251 | boxSizing: 'border-box', 252 | border: `1px solid ${isDark ? '#444' : '#ddd'}`, 253 | fontSize: '0.75rem', 254 | padding: '2px', 255 | color: isDark ? '#ddd' : '#000', 256 | background: isDark 257 | ? rowIndex % 2 === 0 258 | ? '#333' 259 | : '#222' 260 | : rowIndex % 2 === 0 261 | ? '#fafafa' 262 | : '#fff' 263 | }; 264 | 265 | if ( 266 | highlightCell && 267 | rowIndex === highlightCell.row && 268 | columnIndex === highlightCell.column 269 | ) { 270 | cellStyle = { 271 | ...cellStyle, 272 | border: '2px solid #0099cc' 273 | }; 274 | } 275 | 276 | if (rowIndex === 0 || columnIndex === 0) { 277 | cellStyle = { 278 | ...cellStyle, 279 | background: isDark ? '#555' : '#e0e0e0', 280 | fontWeight: 'bold', 281 | textAlign: 'center' 282 | }; 283 | } 284 | 285 | return ( 286 |
    287 | {typeof cellData === 'boolean' 288 | ? cellData 289 | ? 'True' 290 | : 'False' 291 | : cellData} 292 |
    293 | ); 294 | }; 295 | 296 | const handleGotoCell = () => { 297 | const targetGlobalRow = parseInt(cellRowInput, 10); 298 | const targetGlobalCol = parseInt(cellColumnInput, 10); 299 | if ( 300 | !isNaN(targetGlobalRow) && 301 | targetGlobalRow >= 0 && 302 | !isNaN(targetGlobalCol) && 303 | targetGlobalCol >= 0 304 | ) { 305 | const newRowPage = Math.floor(targetGlobalRow / maxRowsRange) + 1; 306 | const newColPage = Math.floor(targetGlobalCol / maxColsRange) + 1; 307 | setRowInput(newRowPage.toString()); 308 | setColumnInput(newColPage.toString()); 309 | const localRow = targetGlobalRow - (newRowPage - 1) * maxRowsRange; 310 | const localCol = targetGlobalCol - (newColPage - 1) * maxColsRange; 311 | const gridRow = fixedRowCount + localRow; 312 | const gridCol = fixedColumnCount + localCol; 313 | setCurrentRow(newRowPage); 314 | setCurrentColumn(newColPage); 315 | setTimeout(() => { 316 | setGotoCell({ row: gridRow, column: gridCol }); 317 | setHighlightCell({ row: gridRow, column: gridCol }); 318 | setTimeout(() => { 319 | setHighlightCell(null); 320 | }, 2000); 321 | }, 500); 322 | } 323 | }; 324 | 325 | if (!allowedTypes.includes(variableType)) { 326 | return ( 327 |
    336 |

    Wrong variable type: {variableType}

    337 |
    338 | ); 339 | } 340 | 341 | return ( 342 |
    351 |
    352 | {/* Grid */} 353 | 354 | {({ width, height }: { width: number; height: number }) => ( 355 | 361 | columnWidths[index] 362 | } 363 | rowHeight={20} 364 | height={height} 365 | rowCount={rowCount} 366 | width={width} 367 | scrollToRow={gotoCell ? gotoCell.row : undefined} 368 | scrollToColumn={gotoCell ? gotoCell.column : undefined} 369 | styleTopLeftGrid={{ background: isDark ? '#555' : '#e0e0e0' }} 370 | styleTopRightGrid={{ background: isDark ? '#555' : '#e0e0e0' }} 371 | styleBottomLeftGrid={{ background: isDark ? '#222' : '#fff' }} 372 | styleBottomRightGrid={{ background: isDark ? '#222' : '#fff' }} 373 | /> 374 | )} 375 | 376 |
    377 |
    378 | {/* pagination */} 379 | 400 |
    401 |
    402 | ); 403 | }; 404 | -------------------------------------------------------------------------------- /src/components/variablePanelWidget.tsx: -------------------------------------------------------------------------------- 1 | import { ReactWidget } from '@jupyterlab/apputils'; 2 | import React from 'react'; 3 | import { VariablePanel } from './variablePanel'; 4 | import { NotebookPanel } from '@jupyterlab/notebook'; 5 | import { VariableRefreshContextProvider } from '../context/variableRefershContext'; 6 | import { ThemeContextProvider } from '../context/themeContext'; 7 | 8 | export interface VariablePanelWidgetProps { 9 | variableName: string; 10 | variableType: string; 11 | variableShape: string; 12 | notebookPanel?: NotebookPanel | null; 13 | } 14 | 15 | export class VariablePanelWidget extends ReactWidget { 16 | constructor(private props: VariablePanelWidgetProps) { 17 | super(); 18 | this.update(); 19 | } 20 | 21 | protected render(): JSX.Element { 22 | return ( 23 |
    24 | 27 | 28 | 34 | 35 | 36 |
    37 | ); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/components/variableRefreshButton.tsx: -------------------------------------------------------------------------------- 1 | import { refreshIcon } from '../icons/refreshIcon'; 2 | import React, { useEffect, useState } from 'react'; 3 | import { useVariableContext } from '../context/notebookVariableContext'; 4 | import { ISettingRegistry } from '@jupyterlab/settingregistry'; 5 | import { VARIABLE_INSPECTOR_ID, autoRefreshProperty } from '../index'; 6 | 7 | interface IProps { 8 | settingRegistry: ISettingRegistry | null; 9 | } 10 | 11 | export const RefreshButton: React.FC = ({ settingRegistry }) => { 12 | const { refreshVariables, loading } = useVariableContext(); 13 | const [autoRefresh, setAutoRefresh] = useState(true); 14 | 15 | const loadAutoRefresh = () => { 16 | if (settingRegistry) { 17 | settingRegistry 18 | .load(VARIABLE_INSPECTOR_ID) 19 | .then(settings => { 20 | const updateSettings = (): void => { 21 | const loadAutoRefresh = settings.get(autoRefreshProperty) 22 | .composite as boolean; 23 | setAutoRefresh(loadAutoRefresh); 24 | }; 25 | updateSettings(); 26 | settings.changed.connect(updateSettings); 27 | }) 28 | .catch(reason => { 29 | console.error( 30 | 'Failed to load settings for Variable Inspector', 31 | reason 32 | ); 33 | }); 34 | } 35 | }; 36 | 37 | useEffect(() => { 38 | loadAutoRefresh(); 39 | }, []); 40 | 41 | return ( 42 | 50 | ); 51 | }; 52 | -------------------------------------------------------------------------------- /src/components/variableSettingsButton.tsx: -------------------------------------------------------------------------------- 1 | import { settingsIcon } from '../icons/settingsIcon'; 2 | import { checkIcon } from '../icons/checkIcon'; 3 | import React, { useEffect, useState } from 'react'; 4 | import { ISettingRegistry } from '@jupyterlab/settingregistry'; 5 | 6 | import { 7 | VARIABLE_INSPECTOR_ID, 8 | // autoRefreshProperty, 9 | showTypeProperty, 10 | showShapeProperty, 11 | showSizeProperty 12 | } from '../index'; 13 | 14 | interface ISettingsButtonProps { 15 | settingRegistry: ISettingRegistry | null; 16 | } 17 | 18 | export const SettingsButton: React.FC = ({ 19 | settingRegistry 20 | }) => { 21 | const [isOpen, setIsOpen] = useState(false); 22 | // const [autoRefresh, setAutoRefresh] = useState(true); 23 | const [showType, setShowType] = useState(false); 24 | const [showShape, setShowShape] = useState(false); 25 | const [showSize, setShowSize] = useState(false); 26 | 27 | const showSettings = () => { 28 | setIsOpen(!isOpen); 29 | }; 30 | 31 | const savePropertyValue = (propertyName: string, newValue: boolean) => { 32 | if (settingRegistry) { 33 | settingRegistry 34 | .load(VARIABLE_INSPECTOR_ID) 35 | .then(settings => { 36 | settings.set(propertyName, newValue); 37 | }) 38 | .catch(reason => { 39 | console.error(`Faild to save ${propertyName}: `, reason); 40 | }); 41 | } 42 | }; 43 | 44 | const loadPropertiesValues = () => { 45 | if (settingRegistry) { 46 | settingRegistry 47 | .load(VARIABLE_INSPECTOR_ID) 48 | .then(settings => { 49 | const updateSettings = (): void => { 50 | // const loadAutoRefresh = settings.get(autoRefreshProperty) 51 | // .composite as boolean; 52 | // setAutoRefresh(loadAutoRefresh); 53 | 54 | const loadShowType = settings.get(showTypeProperty) 55 | .composite as boolean; 56 | setShowType(loadShowType); 57 | 58 | const loadShowShape = settings.get(showShapeProperty) 59 | .composite as boolean; 60 | setShowShape(loadShowShape); 61 | 62 | const loadShowSize = settings.get(showSizeProperty) 63 | .composite as boolean; 64 | setShowSize(loadShowSize); 65 | }; 66 | updateSettings(); 67 | settings.changed.connect(updateSettings); 68 | }) 69 | .catch(reason => { 70 | console.error( 71 | 'Failed to load settings for Variable Inspector', 72 | reason 73 | ); 74 | }); 75 | } 76 | }; 77 | 78 | useEffect(() => { 79 | loadPropertiesValues(); 80 | }, []); 81 | 82 | return ( 83 |
    84 | 91 | 92 | {isOpen && ( 93 |
    94 |
      95 | {/* 108 | 121 |
      */} 122 | 123 | 132 | 141 | 150 |
    151 |
    152 | )} 153 |
    154 | ); 155 | }; 156 | -------------------------------------------------------------------------------- /src/context/codeExecutionContext.tsx: -------------------------------------------------------------------------------- 1 | import React, { 2 | createContext, 3 | useContext, 4 | useEffect, 5 | useState, 6 | ReactNode 7 | } from 'react'; 8 | import { KernelMessage } from '@jupyterlab/services'; 9 | import { IExecuteInputMsg } from '@jupyterlab/services/lib/kernel/messages'; 10 | import { useNotebookPanelContext } from './notebookPanelContext'; 11 | import { useNotebookKernelContext } from './notebookKernelContext'; 12 | import { useVariableContext } from './notebookVariableContext'; 13 | import { VARIABLE_INSPECTOR_ID, autoRefreshProperty } from '../index'; 14 | import { ISettingRegistry } from '@jupyterlab/settingregistry'; 15 | import { variableDict } from '../python_code/getVariables'; 16 | 17 | interface ICodeExecutionContext {} 18 | 19 | interface ICodeExecutionContextProviderProps { 20 | children: ReactNode; 21 | settingRegistry: ISettingRegistry | null; 22 | } 23 | 24 | const CodeExecutionContext = createContext( 25 | undefined 26 | ); 27 | 28 | export const CodeExecutionContextProvider: React.FC< 29 | ICodeExecutionContextProviderProps 30 | > = ({ children, settingRegistry }) => { 31 | const notebook = useNotebookPanelContext(); 32 | const kernelReady = useNotebookKernelContext(); 33 | const { refreshVariables } = useVariableContext(); 34 | const getVariableCode = variableDict; 35 | const [autoRefresh, setAutoRefresh] = useState(true); 36 | 37 | const loadAutoRefresh = () => { 38 | if (settingRegistry) { 39 | settingRegistry 40 | .load(VARIABLE_INSPECTOR_ID) 41 | .then(settings => { 42 | const updateSettings = (): void => { 43 | const loadAutoRefresh = settings.get(autoRefreshProperty) 44 | .composite as boolean; 45 | setAutoRefresh(loadAutoRefresh); 46 | }; 47 | updateSettings(); 48 | settings.changed.connect(updateSettings); 49 | }) 50 | .catch(reason => { 51 | console.error( 52 | 'Failed to load settings for Variable Inspector', 53 | reason 54 | ); 55 | }); 56 | } 57 | }; 58 | 59 | useEffect(() => { 60 | loadAutoRefresh(); 61 | }, []); 62 | 63 | useEffect(() => { 64 | if (!notebook) { 65 | return; 66 | } 67 | const kernel = notebook.sessionContext?.session?.kernel; 68 | if (!kernel) { 69 | return; 70 | } 71 | const handleIOPubMessage = (sender: any, msg: KernelMessage.IMessage) => { 72 | if (msg.header.msg_type === 'execute_input') { 73 | const inputMsg = msg as IExecuteInputMsg; 74 | const code = inputMsg.content.code; 75 | const variableInspectorPrefix = '_jupyterlab_variableinspector'; 76 | const mljarPrefix = '__mljar'; 77 | if ( 78 | code !== getVariableCode && 79 | !code.includes(variableInspectorPrefix) && 80 | !code.includes(mljarPrefix) && 81 | autoRefresh 82 | ) { 83 | refreshVariables(); 84 | } 85 | } 86 | }; 87 | kernel.iopubMessage.connect(handleIOPubMessage); 88 | 89 | return () => { 90 | kernel.iopubMessage.disconnect(handleIOPubMessage); 91 | }; 92 | }, [notebook, notebook?.sessionContext, kernelReady, autoRefresh]); 93 | 94 | return ( 95 | 96 | {children} 97 | 98 | ); 99 | }; 100 | 101 | export const useCodeExecutionContext = (): ICodeExecutionContext => { 102 | const context = useContext(CodeExecutionContext); 103 | if (!context) { 104 | throw new Error( 105 | 'useCodeExecutionContext must be used CodeExecutionContextProvider' 106 | ); 107 | } 108 | return context; 109 | }; 110 | -------------------------------------------------------------------------------- /src/context/notebookKernelContext.tsx: -------------------------------------------------------------------------------- 1 | import React, { createContext, useContext, useEffect, useState } from 'react'; 2 | import { NotebookWatcher, KernelInfo } from '../watchers/notebookWatcher'; 3 | 4 | type NotebookKernelContextType = KernelInfo | null; 5 | 6 | const NotebookKernelContext = createContext(null); 7 | 8 | export function useNotebookKernelContext(): NotebookKernelContextType { 9 | return useContext(NotebookKernelContext); 10 | } 11 | 12 | type NotebookKernelContextProviderProps = { 13 | children: React.ReactNode; 14 | notebookWatcher: NotebookWatcher; 15 | }; 16 | 17 | export function NotebookKernelContextProvider({ 18 | children, 19 | notebookWatcher 20 | }: NotebookKernelContextProviderProps) { 21 | const [kernelInfo, setKernelInfo] = useState( 22 | notebookWatcher.kernelInfo 23 | ); 24 | 25 | useEffect(() => { 26 | const onKernelChanged = ( 27 | sender: NotebookWatcher, 28 | newKernelInfo: KernelInfo | null 29 | ) => { 30 | setKernelInfo(newKernelInfo); 31 | }; 32 | 33 | notebookWatcher.kernelChanged.connect(onKernelChanged); 34 | 35 | setKernelInfo(notebookWatcher.kernelInfo); 36 | 37 | return () => { 38 | notebookWatcher.kernelChanged.disconnect(onKernelChanged); 39 | }; 40 | }, [notebookWatcher]); 41 | 42 | return ( 43 | 44 | {children} 45 | 46 | ); 47 | } 48 | -------------------------------------------------------------------------------- /src/context/notebookPanelContext.tsx: -------------------------------------------------------------------------------- 1 | import React, { createContext, useContext, useEffect, useState } from 'react'; 2 | import { NotebookPanel } from '@jupyterlab/notebook'; 3 | import { NotebookWatcher } from '../watchers/notebookWatcher'; 4 | 5 | type NotebookPanelContextType = NotebookPanel | null; 6 | 7 | const NotebookPanelContext = createContext(null); 8 | 9 | export function useNotebookPanelContext(): NotebookPanelContextType { 10 | return useContext(NotebookPanelContext); 11 | } 12 | 13 | type NotebookPanelContextProviderProps = { 14 | children: React.ReactNode; 15 | notebookWatcher: NotebookWatcher; 16 | }; 17 | 18 | export function NotebookPanelContextProvider({ 19 | children, 20 | notebookWatcher 21 | }: NotebookPanelContextProviderProps) { 22 | const [notebookPanel, setNotebookPanel] = useState( 23 | notebookWatcher.notebookPanel() 24 | ); 25 | 26 | useEffect(() => { 27 | const onNotebookPanelChange = ( 28 | sender: NotebookWatcher, 29 | newNotebookPanel: NotebookPanel | null 30 | ) => { 31 | setNotebookPanel(newNotebookPanel); 32 | }; 33 | 34 | notebookWatcher.notebookPanelChanged.connect(onNotebookPanelChange); 35 | 36 | setNotebookPanel(notebookWatcher.notebookPanel()); 37 | 38 | return () => { 39 | notebookWatcher.notebookPanelChanged.disconnect(onNotebookPanelChange); 40 | }; 41 | }, [notebookWatcher]); 42 | 43 | return ( 44 | 45 | {children} 46 | 47 | ); 48 | } 49 | -------------------------------------------------------------------------------- /src/context/notebookVariableContext.tsx: -------------------------------------------------------------------------------- 1 | import React, { 2 | createContext, 3 | useContext, 4 | useState, 5 | useEffect, 6 | useCallback 7 | } from 'react'; 8 | import { useNotebookPanelContext } from './notebookPanelContext'; 9 | import { useNotebookKernelContext } from './notebookKernelContext'; 10 | import { KernelMessage } from '@jupyterlab/services'; 11 | import { IStateDB } from '@jupyterlab/statedb'; 12 | import { withIgnoredSidebarKernelUpdates } from '../utils/kernelOperationNotifier'; 13 | import { variableDict } from '../python_code/getVariables'; 14 | import { CommandRegistry } from '@lumino/commands'; 15 | 16 | export interface IVariableInfo { 17 | name: string; 18 | type: string; 19 | shape: string; 20 | dimension: number; 21 | size: number; 22 | value: string; 23 | } 24 | 25 | interface IVariableContextProps { 26 | variables: IVariableInfo[]; 27 | loading: boolean; 28 | error: string | null; 29 | searchTerm: string; 30 | setSearchTerm: React.Dispatch>; 31 | refreshVariables: () => void; 32 | isRefreshing: boolean; 33 | refreshCount: number; 34 | } 35 | 36 | const VariableContext = createContext( 37 | undefined 38 | ); 39 | 40 | type Task = () => Promise | void; 41 | 42 | class DebouncedTaskQueue { 43 | // Holds the timer handle. 44 | private timer: ReturnType | null = null; 45 | // Holds the most recently added task. 46 | private lastTask: Task | null = null; 47 | private delay: number; 48 | 49 | /** 50 | * @param delay Time in milliseconds to wait before executing the last task. 51 | */ 52 | constructor(delay: number = 500) { 53 | this.delay = delay; 54 | } 55 | 56 | /** 57 | * Adds a new task to the queue. Only the last task added within the delay period will be executed. 58 | * @param task A function representing the task. 59 | */ 60 | add(task: Task): void { 61 | // Save (or overwrite) the latest task. 62 | this.lastTask = task; 63 | 64 | // If there’s already a pending timer, clear it. 65 | if (this.timer) { 66 | clearTimeout(this.timer); 67 | } 68 | 69 | // Start (or restart) the timer. 70 | this.timer = setTimeout(async () => { 71 | if (this.lastTask) { 72 | try { 73 | // Execute the latest task. 74 | await this.lastTask(); 75 | } catch (error) { 76 | console.error('Task execution failed:', error); 77 | } 78 | } 79 | // After execution, clear the stored task and timer. 80 | this.lastTask = null; 81 | this.timer = null; 82 | }, this.delay); 83 | } 84 | } 85 | 86 | export const VariableContextProvider: React.FC<{ 87 | children: React.ReactNode; 88 | stateDB: IStateDB; 89 | commands: CommandRegistry; 90 | }> = ({ children, stateDB, commands }) => { 91 | const notebookPanel = useNotebookPanelContext(); 92 | const kernel = useNotebookKernelContext(); 93 | const [variables, setVariables] = useState([]); 94 | const [loading, setLoading] = useState(false); 95 | const [error, setError] = useState(null); 96 | const [searchTerm, setSearchTerm] = useState(''); 97 | const [isRefreshing, setIsRefreshing] = useState(false); 98 | const [refreshCount, setRefreshCount] = useState(0); 99 | const queue = new DebouncedTaskQueue(250); 100 | 101 | const executeCode = useCallback(async () => { 102 | await withIgnoredSidebarKernelUpdates(async () => { 103 | //setIsRefreshing(true); 104 | //setLoading(true); 105 | stateDB.save('mljarVariablesStatus', 'loading'); 106 | setError(null); 107 | if (!notebookPanel) { 108 | setVariables([]); 109 | setLoading(false); 110 | setIsRefreshing(false); 111 | stateDB.save('mljarVariables', []); 112 | return; 113 | } 114 | //setVariables([]); 115 | try { 116 | await notebookPanel.sessionContext?.ready; 117 | const future = 118 | notebookPanel.sessionContext?.session?.kernel?.requestExecute({ 119 | code: variableDict, 120 | store_history: false 121 | }); 122 | if (future) { 123 | future.onIOPub = (msg: KernelMessage.IIOPubMessage) => { 124 | const msgType = msg.header.msg_type; 125 | if ( 126 | msgType === 'execute_result' || 127 | msgType === 'display_data' || 128 | msgType === 'update_display_data' || 129 | msgType === 'error' 130 | ) { 131 | const content = msg.content as any; 132 | const jsonData = content.data['application/json']; 133 | const textData = content.data['text/plain']; 134 | if (jsonData) { 135 | setLoading(false); 136 | setIsRefreshing(false); 137 | setRefreshCount(prev => prev + 1); 138 | } else if (textData) { 139 | try { 140 | const cleanedData = textData.replace(/^['"]|['"]$/g, ''); 141 | const doubleQuotedData = cleanedData.replace(/'/g, '"'); 142 | const parsedData: IVariableInfo[] = 143 | JSON.parse(doubleQuotedData); 144 | if (Array.isArray(parsedData)) { 145 | const mappedVariables: IVariableInfo[] = parsedData.map( 146 | (item: any) => ({ 147 | name: item.varName, 148 | type: item.varType, 149 | shape: item.varShape || 'None', 150 | dimension: item.varDimension, 151 | size: item.varSize, 152 | value: item.varSimpleValue 153 | }) 154 | ); 155 | setVariables(mappedVariables); 156 | 157 | stateDB.save( 158 | 'mljarVariables', 159 | JSON.parse(doubleQuotedData) 160 | ); 161 | stateDB.save('mljarVariablesStatus', 'loaded'); 162 | 163 | commands 164 | .execute('mljar-piece-of-code:refresh-variables') 165 | .catch(err => {}); 166 | } else { 167 | throw new Error('Error during parsing.'); 168 | } 169 | setLoading(false); 170 | setIsRefreshing(false); 171 | setRefreshCount(prev => prev + 1); 172 | } catch (err) { 173 | setError('Error during export JSON.'); 174 | setVariables([]); 175 | setLoading(false); 176 | setIsRefreshing(false); 177 | stateDB.save('mljarVariablesStatus', 'error'); 178 | } 179 | } 180 | } 181 | }; 182 | await future.done; 183 | stateDB.save('mljarVariablesStatus', 'loaded'); 184 | } 185 | } catch (err) { 186 | setError('Unexpected error.'); 187 | setLoading(false); 188 | setIsRefreshing(false); 189 | stateDB.save('mljarVariablesStatus', 'error'); 190 | } 191 | }); 192 | return; 193 | }, [notebookPanel, kernel]); 194 | 195 | useEffect(() => { 196 | stateDB.save('mljarVariablesStatus', 'loading'); 197 | queue.add(() => executeCode()); 198 | }, [executeCode]); 199 | 200 | return ( 201 | { 209 | stateDB.save('mljarVariablesStatus', 'loading'); 210 | queue.add(() => executeCode()); 211 | }, 212 | isRefreshing, 213 | refreshCount 214 | }} 215 | > 216 | {children} 217 | 218 | ); 219 | }; 220 | 221 | export const useVariableContext = (): IVariableContextProps => { 222 | const context = useContext(VariableContext); 223 | if (context === undefined) { 224 | throw new Error( 225 | 'useVariableContext must be used within a VariableProvider' 226 | ); 227 | } 228 | return context; 229 | }; 230 | -------------------------------------------------------------------------------- /src/context/pluginVisibilityContext.tsx: -------------------------------------------------------------------------------- 1 | import React, { createContext, useState, useContext } from 'react'; 2 | 3 | export interface PluginVisibilityContextValue { 4 | isPluginOpen: boolean; 5 | setPluginOpen: (open: boolean) => void; 6 | } 7 | 8 | export const PluginVisibilityContext = 9 | createContext({ 10 | isPluginOpen: false, 11 | setPluginOpen: () => { } 12 | }); 13 | 14 | export function PluginVisibilityProvider({ 15 | children 16 | }: { 17 | children: React.ReactNode; 18 | }) { 19 | const [isPluginOpen, setPluginOpen] = useState(false); 20 | return ( 21 | 22 | {children} 23 | 24 | ); 25 | } 26 | 27 | export function usePluginVisibility() { 28 | return useContext(PluginVisibilityContext); 29 | } 30 | -------------------------------------------------------------------------------- /src/context/themeContext.tsx: -------------------------------------------------------------------------------- 1 | import React, { createContext, useEffect, useState, useContext } from 'react'; 2 | 3 | interface ThemeContextProps { 4 | isDark: boolean; 5 | } 6 | 7 | const ThemeContext = createContext({ isDark: false }); 8 | 9 | export const ThemeContextProvider: React.FC<{children: React.ReactNode}> = ( {children} ) => { 10 | const [isDark, setIsDark] = useState(() => { 11 | const theme = document.body.dataset.jpThemeName; 12 | return theme ? theme.includes('Dark') : false; 13 | }); 14 | 15 | useEffect(() => { 16 | const observer = new MutationObserver(mutations => { 17 | mutations.forEach(mutation => { 18 | if (mutation.type === 'attributes' && mutation.attributeName === 'data-jp-theme-name') { 19 | const theme = document.body.getAttribute('data-jp-theme-name'); 20 | setIsDark(theme?.includes('Dark') ?? false); 21 | } 22 | }); 23 | }); 24 | observer.observe(document.body, { 25 | attributes: true, 26 | attributeFilter: ['data-jp-theme-name'] 27 | }); 28 | return () => { 29 | observer.disconnect(); 30 | }; 31 | }, []); 32 | 33 | return ( 34 | 35 | {children} 36 | 37 | ); 38 | }; 39 | 40 | export const useThemeContext = () => useContext(ThemeContext); 41 | -------------------------------------------------------------------------------- /src/context/variableRefershContext.tsx: -------------------------------------------------------------------------------- 1 | import { NotebookPanel } from '@jupyterlab/notebook'; 2 | import React, { createContext, useContext, useEffect, useState } from 'react'; 3 | import { kernelOperationNotifier } from '../utils/kernelOperationNotifier'; 4 | 5 | interface VariableRefreshContextValue { 6 | refreshCount: number; 7 | } 8 | 9 | const VariableRefreshContext = createContext({ 10 | refreshCount: 0 11 | }); 12 | 13 | interface VariableRefreshContextProviderProps { 14 | children: React.ReactNode; 15 | notebookPanel?: NotebookPanel | null; 16 | } 17 | 18 | export const VariableRefreshContextProvider: React.FC< 19 | VariableRefreshContextProviderProps 20 | > = ({ children, notebookPanel }) => { 21 | const [refreshCount, setRefreshCount] = useState(0); 22 | 23 | useEffect(() => { 24 | if (!notebookPanel) { 25 | return; 26 | } 27 | 28 | const kernel = notebookPanel.sessionContext.session?.kernel; 29 | if (!kernel) { 30 | return; 31 | } 32 | 33 | const onSidebarStatusChange = (_sender: any, inProgress: boolean) => { 34 | if (inProgress === true) { 35 | setRefreshCount(prev => prev + 1); 36 | } 37 | }; 38 | 39 | kernelOperationNotifier.sidebarOperationChanged.connect( 40 | onSidebarStatusChange 41 | ); 42 | 43 | return () => { 44 | kernelOperationNotifier.sidebarOperationChanged.disconnect( 45 | onSidebarStatusChange 46 | ); 47 | }; 48 | }, [notebookPanel]); 49 | 50 | return ( 51 | 52 | {children} 53 | 54 | ); 55 | }; 56 | 57 | export const useVariableRefeshContext = () => 58 | useContext(VariableRefreshContext); 59 | -------------------------------------------------------------------------------- /src/icons/checkIcon.ts: -------------------------------------------------------------------------------- 1 | import { LabIcon } from '@jupyterlab/ui-components'; 2 | 3 | const svgStr = ` 4 | 5 | `; 6 | 7 | export const checkIcon = new LabIcon({ 8 | name: 'my-variable-check-icon', 9 | svgstr: svgStr 10 | }); 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/icons/detailIcon.ts: -------------------------------------------------------------------------------- 1 | import { LabIcon } from '@jupyterlab/ui-components'; 2 | 3 | const svgStr = ` 4 | 5 | `; 6 | 7 | export const detailIcon = new LabIcon({ 8 | name: 'detail-plugin-icon', 9 | svgstr: svgStr, 10 | }); 11 | 12 | -------------------------------------------------------------------------------- /src/icons/gridScanIcon.ts: -------------------------------------------------------------------------------- 1 | import { LabIcon } from '@jupyterlab/ui-components'; 2 | 3 | const svgStr = ` 4 | 5 | `; 6 | 7 | export const gridScanIcon = new LabIcon({ 8 | name: 'grid-scan-icon', 9 | svgstr: svgStr, 10 | }); 11 | 12 | -------------------------------------------------------------------------------- /src/icons/panelIcon.ts: -------------------------------------------------------------------------------- 1 | import { LabIcon } from '@jupyterlab/ui-components'; 2 | 3 | const svgStr = ` 4 | 5 | `; 6 | 7 | export const panelIcon = new LabIcon({ 8 | name: 'inspector-panel-icon', 9 | svgstr: svgStr, 10 | }); 11 | 12 | -------------------------------------------------------------------------------- /src/icons/pluginIcon.ts: -------------------------------------------------------------------------------- 1 | import { LabIcon } from '@jupyterlab/ui-components'; 2 | 3 | const svgStr = ` 4 | 5 | `; 6 | 7 | export const pluginIcon = new LabIcon({ 8 | name: 'variable-plugin-icon', 9 | svgstr: svgStr, 10 | }); 11 | 12 | -------------------------------------------------------------------------------- /src/icons/refreshIcon.ts: -------------------------------------------------------------------------------- 1 | import { LabIcon } from '@jupyterlab/ui-components'; 2 | 3 | const svgStr = ` 4 | 5 | `; 6 | 7 | export const refreshIcon = new LabIcon({ 8 | name: 'my-variable-refresh-icon', 9 | svgstr: svgStr 10 | }); 11 | -------------------------------------------------------------------------------- /src/icons/settingsIcon.ts: -------------------------------------------------------------------------------- 1 | import { LabIcon } from '@jupyterlab/ui-components'; 2 | 3 | const svgStr = ` 4 | 5 | `; 6 | 7 | export const settingsIcon = new LabIcon({ 8 | name: 'my-variable-settings-icon', 9 | svgstr: svgStr 10 | }); 11 | 12 | -------------------------------------------------------------------------------- /src/icons/skipLeftIcon.ts: -------------------------------------------------------------------------------- 1 | import { LabIcon } from '@jupyterlab/ui-components'; 2 | 3 | const svgStr = ` 4 | 5 | `; 6 | 7 | export const skipLeftIcon = new LabIcon({ 8 | name: 'my-variable-skip-left-icon', 9 | svgstr: svgStr 10 | }); 11 | -------------------------------------------------------------------------------- /src/icons/skipRightIcon.ts: -------------------------------------------------------------------------------- 1 | import { LabIcon } from '@jupyterlab/ui-components'; 2 | 3 | const svgStr = ` 4 | 5 | `; 6 | 7 | export const skipRightIcon = new LabIcon({ 8 | name: 'my-variable-skip-right-icon', 9 | svgstr: svgStr 10 | }); 11 | 12 | -------------------------------------------------------------------------------- /src/icons/smallSkipLeftIcon.ts: -------------------------------------------------------------------------------- 1 | import { LabIcon } from '@jupyterlab/ui-components'; 2 | 3 | const svgStr = ` 4 | `; 5 | 6 | export const smallSkipLeftIcon = new LabIcon({ 7 | name: 'mljar-variable-inspector-small-skip-left-icon', 8 | svgstr: svgStr 9 | }); 10 | -------------------------------------------------------------------------------- /src/icons/smallSkipRightIcon.ts: -------------------------------------------------------------------------------- 1 | import { LabIcon } from '@jupyterlab/ui-components'; 2 | 3 | const svgStr = ` 4 | ` 5 | export const smallSkipRightIcon = new LabIcon({ 6 | name: 'mljar-variable-inspector-small-skip-right-icon', 7 | svgstr: svgStr 8 | }); 9 | -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | import { 2 | JupyterFrontEnd, 3 | JupyterFrontEndPlugin, 4 | ILabShell 5 | } from '@jupyterlab/application'; 6 | 7 | import { ISettingRegistry } from '@jupyterlab/settingregistry'; 8 | import { IStateDB } from '@jupyterlab/statedb'; 9 | 10 | import { createVariableInspectorSidebar } from './components/variableInspectorSidebar'; 11 | import { NotebookWatcher } from './watchers/notebookWatcher'; 12 | 13 | export const VARIABLE_INSPECTOR_ID = 'variable-inspector:plugin'; 14 | export const autoRefreshProperty = 'variableInspectorAutoRefresh'; 15 | export const showTypeProperty = 'variableInspectorShowType'; 16 | export const showShapeProperty = 'variableInspectorShowShape'; 17 | export const showSizeProperty = 'variableInspectorShowSize'; 18 | 19 | const leftTab: JupyterFrontEndPlugin = { 20 | id: VARIABLE_INSPECTOR_ID, 21 | description: 'A JupyterLab extension to easy manage variables.', 22 | autoStart: true, 23 | requires: [ILabShell, ISettingRegistry, IStateDB], 24 | activate: async ( 25 | app: JupyterFrontEnd, 26 | labShell: ILabShell, 27 | settingregistry: ISettingRegistry | null, 28 | stateDB: IStateDB 29 | ) => { 30 | const notebookWatcher = new NotebookWatcher(app.shell); 31 | const widget = createVariableInspectorSidebar( 32 | notebookWatcher, 33 | app.commands, 34 | labShell, 35 | settingregistry, 36 | stateDB 37 | ); 38 | // initialize variables list 39 | stateDB.save('mljarVariablesStatus', 'loaded'); 40 | stateDB.save('mljarVariables', []); 41 | 42 | app.shell.add(widget, 'left', { rank: 1998 }); 43 | } 44 | }; 45 | 46 | export default [leftTab]; 47 | -------------------------------------------------------------------------------- /src/python_code/getMatrix.ts: -------------------------------------------------------------------------------- 1 | export const getMatrix = ( 2 | varName: string, 3 | startRow: number, 4 | endRow: number, 5 | startColumn: number, 6 | endColumn: number 7 | ): string => ` 8 | import importlib 9 | from IPython.display import JSON 10 | 11 | def __get_variable_shape(obj): 12 | if hasattr(obj, 'shape'): 13 | return " x ".join(map(str, obj.shape)) 14 | if isinstance(obj, list): 15 | if obj and all(isinstance(el, list) for el in obj): 16 | if len(set(map(len, obj))) == 1: 17 | return f"{len(obj)} x {len(obj[0])}" 18 | else: 19 | return f"{len(obj)}" 20 | return str(len(obj)) 21 | return "" 22 | 23 | def __format_content(item): 24 | if isinstance(item, list): 25 | return [__format_content(subitem) for subitem in item] 26 | elif isinstance(item, dict): 27 | return {k: __format_content(v) for k, v in item.items()} 28 | elif isinstance(item, str): 29 | return item[:50] + "..." if len(item) > 50 else item 30 | elif isinstance(item, (int, float, bool)) or item is None: 31 | return item 32 | else: 33 | if hasattr(item, "name"): 34 | return getattr(item, "name") 35 | return type(item).__name__ 36 | 37 | def __mljar_variable_inspector_get_matrix_content( 38 | var_name="${varName}", 39 | start_row=${startRow}, 40 | end_row=${endRow}, 41 | start_column=${startColumn}, 42 | end_column=${endColumn} 43 | ): 44 | if var_name not in globals(): 45 | return JSON({"error": "Variable not found."}) 46 | 47 | obj = globals()[var_name] 48 | module_name = type(obj).__module__ 49 | var_type = type(obj).__name__ 50 | var_shape = __get_variable_shape(obj) 51 | 52 | if "numpy" in module_name: 53 | try: 54 | np = importlib.import_module("numpy") 55 | except ImportError: 56 | return JSON({"error": "Numpy is not installed."}) 57 | if isinstance(obj, np.ndarray): 58 | if obj.ndim > 2: 59 | return JSON({ 60 | "variable": var_name, 61 | "variableType": var_type, 62 | "variableShape": var_shape, 63 | "error": "Numpy array has more than 2 dimensions." 64 | }) 65 | if obj.ndim == 1: 66 | actual_end_row = min(end_row, len(obj)) 67 | sliced = obj[start_row:actual_end_row] 68 | returnedSize = [start_row, actual_end_row, 0, 1] 69 | else: 70 | actual_end_row = min(end_row, obj.shape[0]) 71 | actual_end_column = min(end_column, obj.shape[1]) 72 | sliced = obj[start_row:actual_end_row, start_column:actual_end_column] 73 | returnedSize = [start_row, actual_end_row, start_column, actual_end_column] 74 | return JSON({ 75 | "variable": var_name, 76 | "variableType": var_type, 77 | "variableShape": var_shape, 78 | "returnedSize": returnedSize, 79 | "content": __format_content(sliced.tolist()) 80 | }) 81 | 82 | if "pandas" in module_name: 83 | try: 84 | pd = importlib.import_module("pandas") 85 | except ImportError: 86 | return JSON({"error": "Pandas is not installed."}) 87 | if isinstance(obj, pd.DataFrame): 88 | actual_end_row = min(end_row, len(obj.index)) 89 | actual_end_column = min(end_column, len(obj.columns)) 90 | sliced = obj.iloc[start_row:actual_end_row, start_column:actual_end_column] 91 | result = [] 92 | for col in sliced.columns: 93 | col_values = [col] + sliced[col].tolist() 94 | result.append(col_values) 95 | returnedSize = [start_row, actual_end_row, start_column, actual_end_column] 96 | return JSON({ 97 | "variable": var_name, 98 | "variableType": var_type, 99 | "variableShape": var_shape, 100 | "returnedSize": returnedSize, 101 | "content": __format_content(result) 102 | }) 103 | elif isinstance(obj, pd.Series): 104 | actual_end_row = min(end_row, len(obj)) 105 | sliced = obj.iloc[start_row:actual_end_row] 106 | df = sliced.to_frame() 107 | result = [] 108 | for col in df.columns: 109 | col_values = [col] + df[col].tolist() 110 | result.append(col_values) 111 | returnedSize = [start_row, actual_end_row, 0, 1] 112 | return JSON({ 113 | "variable": var_name, 114 | "variableType": var_type, 115 | "variableShape": var_shape, 116 | "returnedSize": returnedSize, 117 | "content": __format_content(result) 118 | }) 119 | 120 | if isinstance(obj, list): 121 | if all(isinstance(el, list) for el in obj): 122 | if len(set(map(len, obj))) == 1: 123 | actual_end_row = min(end_row, len(obj)) 124 | actual_end_column = min(end_column, len(obj[0])) 125 | sliced = [row[start_column:actual_end_column] for row in obj[start_row:actual_end_row]] 126 | returnedSize = [start_row, actual_end_row, start_column, actual_end_column] 127 | content = __format_content(sliced) 128 | else: 129 | actual_end_row = min(end_row, len(obj)) 130 | sliced = obj[start_row:actual_end_row] 131 | returnedSize = [start_row, actual_end_row, 0, 1] 132 | content = ["list" for _ in sliced] 133 | var_shape = f"{len(obj)}" 134 | return JSON({ 135 | "variable": var_name, 136 | "variableType": var_type, 137 | "variableShape": var_shape, 138 | "returnedSize": returnedSize, 139 | "content": content 140 | }) 141 | else: 142 | actual_end_row = min(end_row, len(obj)) 143 | sliced = obj[start_row:actual_end_row] 144 | returnedSize = [start_row, actual_end_row, 0, 1] 145 | return JSON({ 146 | "variable": var_name, 147 | "variableType": var_type, 148 | "variableShape": str(len(obj)), 149 | "returnedSize": returnedSize, 150 | "content": __format_content(sliced) 151 | }) 152 | 153 | if isinstance(obj, dict): 154 | items = list(obj.items())[start_row:end_row] 155 | sliced_dict = dict(items) 156 | returnedSize = [start_row, end_row, 0, 1] 157 | var_shape = str(len(obj)) 158 | return JSON({ 159 | "variable": var_name, 160 | "variableType": var_type, 161 | "variableShape": var_shape, 162 | "returnedSize": returnedSize, 163 | "content": __format_content(sliced_dict) 164 | }) 165 | 166 | return JSON({ 167 | "variable": var_name, 168 | "variableType": var_type, 169 | "variableShape": "unknown", 170 | "error": "Variable is not a supported array type.", 171 | "content": [10, 10, 10] 172 | }) 173 | 174 | __mljar_variable_inspector_get_matrix_content() 175 | `; 176 | -------------------------------------------------------------------------------- /src/python_code/getVariables.ts: -------------------------------------------------------------------------------- 1 | export const variableDict = ` 2 | import json 3 | import sys 4 | import math 5 | from importlib import __import__ 6 | from IPython import get_ipython 7 | from IPython.core.magics.namespace import NamespaceMagics 8 | 9 | __mljar_variable_inspector_nms = NamespaceMagics() 10 | __mljar_variable_inspector_Jupyter = get_ipython() 11 | __mljar_variable_inspector_nms.shell = __mljar_variable_inspector_Jupyter.kernel.shell 12 | 13 | __np = None 14 | __pd = None 15 | __pyspark = None 16 | __tf = None 17 | __K = None 18 | __torch = None 19 | __ipywidgets = None 20 | __xr = None 21 | 22 | 23 | def __mljar_variable_inspector_attempt_import(module): 24 | try: 25 | return __import__(module) 26 | except ImportError: 27 | return None 28 | 29 | 30 | def __mljar_variable_inspector_check_imported(): 31 | global __np, __pd, __pyspark, __tf, __K, __torch, __ipywidgets, __xr 32 | 33 | __np = __mljar_variable_inspector_attempt_import('numpy') 34 | __pd = __mljar_variable_inspector_attempt_import('pandas') 35 | __pyspark = __mljar_variable_inspector_attempt_import('pyspark') 36 | __tf = __mljar_variable_inspector_attempt_import('tensorflow') 37 | __K = __mljar_variable_inspector_attempt_import('keras.backend') or __mljar_variable_inspector_attempt_import('tensorflow.keras.backend') 38 | __torch = __mljar_variable_inspector_attempt_import('torch') 39 | __ipywidgets = __mljar_variable_inspector_attempt_import('ipywidgets') 40 | __xr = __mljar_variable_inspector_attempt_import('xarray') 41 | 42 | 43 | def __mljar_variable_inspector_getshapeof(x): 44 | def get_list_shape(lst): 45 | if isinstance(lst, list): 46 | if not lst: 47 | return "0" 48 | sub_shape = get_list_shape(lst[0]) 49 | return f"{len(lst)}" if sub_shape == "" else f"{len(lst)} x {sub_shape}" 50 | else: 51 | return "" 52 | 53 | if __pd and isinstance(x, __pd.DataFrame): 54 | return "%d x %d" % x.shape 55 | if __pd and isinstance(x, __pd.Series): 56 | return "%d" % x.shape 57 | if __np and isinstance(x, __np.ndarray): 58 | shape = " x ".join([str(i) for i in x.shape]) 59 | return "%s" % shape 60 | if __pyspark and isinstance(x, __pyspark.sql.DataFrame): 61 | return "? x %d" % len(x.columns) 62 | if __tf and isinstance(x, __tf.Variable): 63 | shape = " x ".join([str(int(i)) for i in x.shape]) 64 | return "%s" % shape 65 | if __tf and isinstance(x, __tf.Tensor): 66 | shape = " x ".join([str(int(i)) for i in x.shape]) 67 | return "%s" % shape 68 | if __torch and isinstance(x, __torch.Tensor): 69 | shape = " x ".join([str(int(i)) for i in x.shape]) 70 | return "%s" % shape 71 | if __xr and isinstance(x, __xr.DataArray): 72 | shape = " x ".join([str(int(i)) for i in x.shape]) 73 | return "%s" % shape 74 | if isinstance(x, list): 75 | return get_list_shape(x) 76 | if isinstance(x, dict): 77 | return "%s keys" % len(x) 78 | return None 79 | 80 | 81 | def __format_content(item): 82 | if isinstance(item, list): 83 | return __format_content(str([__format_content(subitem) for subitem in item])) 84 | elif isinstance(item, dict): 85 | return __format_content(str({k: __format_content(v) for k, v in item.items()})) 86 | elif isinstance(item, str): 87 | return item[:100] + "..." if len(item) > 100 else item 88 | elif isinstance(item, (int, float, bool, set)) or item is None: 89 | return item 90 | else: 91 | if hasattr(item, "name"): 92 | return getattr(item, "name") 93 | return type(item).__name__ 94 | 95 | def __mljar_variable_inspector_get_simple_value(x): 96 | if isinstance(x, bytes): 97 | return "" 98 | if x is None: 99 | return "None" 100 | if __np is not None and __np.isscalar(x) and not isinstance(x, bytes): 101 | return str(x) 102 | if isinstance(x, (int, float, complex, bool, str, set, list, dict)): 103 | strValue = str(x) #__format_content(x) 104 | if len(strValue) > 100: 105 | return strValue[:100] + "..." 106 | else: 107 | return strValue 108 | # if isinstance(x, (list, dict)): 109 | # return __format_content(x) 110 | 111 | return "" 112 | 113 | 114 | def __mljar_variable_inspector_size_converter(size): 115 | if size == 0: 116 | return '0B' 117 | units = ['B', 'kB', 'MB', 'GB', 'TB'] 118 | index = math.floor(math.log(size, 1024)) 119 | divider = math.pow(1024, index) 120 | converted_size = round(size / divider, 2) 121 | return f"{converted_size} {units[index]}" 122 | 123 | 124 | def __mljar_variableinspector_is_matrix(x): 125 | # True if type(x).__name__ in ["DataFrame", "ndarray", "Series"] else False 126 | if __pd and isinstance(x, __pd.DataFrame): 127 | return True 128 | if __pd and isinstance(x, __pd.Series): 129 | return True 130 | if __np and isinstance(x, __np.ndarray) and len(x.shape) <= 2: 131 | return True 132 | if __pyspark and isinstance(x, __pyspark.sql.DataFrame): 133 | return True 134 | if __tf and isinstance(x, __tf.Variable) and len(x.shape) <= 2: 135 | return True 136 | if __tf and isinstance(x, __tf.Tensor) and len(x.shape) <= 2: 137 | return True 138 | if __torch and isinstance(x, __torch.Tensor) and len(x.shape) <= 2: 139 | return True 140 | if __xr and isinstance(x, __xr.DataArray) and len(x.shape) <= 2: 141 | return True 142 | if isinstance(x, list): 143 | return True 144 | return False 145 | 146 | 147 | def __mljar_variableinspector_is_widget(x): 148 | return __ipywidgets and issubclass(x, __ipywidgets.DOMWidget) 149 | 150 | def __mljar_variableinspector_getcolumnsof(x): 151 | if __pd and isinstance(x, __pd.DataFrame): 152 | return list(x.columns) 153 | return [] 154 | 155 | def __mljar_variableinspector_getcolumntypesof(x): 156 | if __pd and isinstance(x, __pd.DataFrame): 157 | return [str(t) for t in x.dtypes] 158 | return [] 159 | 160 | def __mljar_variable_inspector_dict_list(): 161 | __mljar_variable_inspector_check_imported() 162 | def __mljar_variable_inspector_keep_cond(v): 163 | try: 164 | obj = eval(v) 165 | if isinstance(obj, str): 166 | return True 167 | if __tf and isinstance(obj, __tf.Variable): 168 | return True 169 | if __pd and __pd is not None and ( 170 | isinstance(obj, __pd.core.frame.DataFrame) 171 | or isinstance(obj, __pd.core.series.Series)): 172 | return True 173 | if __xr and __xr is not None and isinstance(obj, __xr.DataArray): 174 | return True 175 | if str(obj).startswith(" 2 222 | - For Series -> 1 223 | - For NDarray -> korzysta z atrybutu ndim 224 | - For pyspark DataFrame -> 2 225 | - For TensorFlow, PyTorch, xarray -> shape length 226 | - For list -> nesting depth 227 | - For sklar type (int, float, itp.) -> 1 228 | - For other objects or dict -> 0 229 | """ 230 | if __pd and isinstance(x, __pd.DataFrame): 231 | return 2 232 | if __pd and isinstance(x, __pd.Series): 233 | return 1 234 | if __np and isinstance(x, __np.ndarray): 235 | return x.ndim 236 | if __pyspark and isinstance(x, __pyspark.sql.DataFrame): 237 | return 2 238 | if __tf and (isinstance(x, __tf.Variable) or isinstance(x, __tf.Tensor)): 239 | try: 240 | return len(x.shape) 241 | except Exception: 242 | return 0 243 | if __torch and isinstance(x, __torch.Tensor): 244 | return len(x.shape) 245 | if __xr and isinstance(x, __xr.DataArray): 246 | return len(x.shape) 247 | if isinstance(x, list): 248 | def __mljar_variable_inspector_list_depth(lst): 249 | if isinstance(lst, list) and lst: 250 | subdepths = [__mljar_variable_inspector_list_depth(el) for el in lst if isinstance(el, list)] 251 | if subdepths: 252 | return 1 + max(subdepths) 253 | else: 254 | return 1 255 | else: 256 | return 0 257 | return __mljar_variable_inspector_list_depth(x) 258 | if isinstance(x, (int, float, complex, bool, str)): 259 | return 1 260 | if isinstance(x, dict): 261 | return 0 262 | return 0 263 | 264 | 265 | def __mljar_variable_inspector_getmatrixcontent(x, max_rows=10000): 266 | # to do: add something to handle this in the future 267 | threshold = max_rows 268 | 269 | if __pd and __pyspark and isinstance(x, __pyspark.sql.DataFrame): 270 | df = x.limit(threshold).toPandas() 271 | return __mljar_variable_inspector_getmatrixcontent(df.copy()) 272 | elif __np and __pd and type(x).__name__ == "DataFrame": 273 | if threshold is not None: 274 | x = x.head(threshold) 275 | x.columns = x.columns.map(str) 276 | return x.to_json(orient="table", default_handler= __mljar_variable_inspector_default, force_ascii=False) 277 | elif __np and __pd and type(x).__name__ == "Series": 278 | if threshold is not None: 279 | x = x.head(threshold) 280 | return x.to_json(orient="table", default_handler= __mljar_variable_inspector_default, force_ascii=False) 281 | elif __np and __pd and type(x).__name__ == "ndarray": 282 | df = __pd.DataFrame(x) 283 | return __mljar_variable_inspector_getmatrixcontent(df) 284 | elif __tf and (isinstance(x, __tf.Variable) or isinstance(x, __tf.Tensor)): 285 | df = __K.get_value(x) 286 | return __mljar_variable_inspector_getmatrixcontent(df) 287 | elif __torch and isinstance(x, __torch.Tensor): 288 | df = x.cpu().numpy() 289 | return __mljar_variable_inspector_getmatrixcontent(df) 290 | elif __xr and isinstance(x, __xr.DataArray): 291 | df = x.to_numpy() 292 | return __mljar_variable_inspector_getmatrixcontent(df) 293 | elif isinstance(x, list): 294 | s = __pd.Series(x) 295 | return __mljar_variable_inspector_getmatrixcontent(s) 296 | 297 | 298 | def __mljar_variable_inspector_displaywidget(widget): 299 | display(widget) 300 | 301 | 302 | def __mljar_variable_inspector_default(o): 303 | if isinstance(o, __np.number): return int(o) 304 | raise TypeError 305 | 306 | 307 | def __mljar_variable_inspector_deletevariable(x): 308 | exec("del %s" % x, globals()) 309 | 310 | __mljar_variable_inspector_dict_list() 311 | `; 312 | -------------------------------------------------------------------------------- /src/utils/allowedTypes.ts: -------------------------------------------------------------------------------- 1 | export const allowedTypes = ['ndarray', 'DataFrame', 'list', 'Series', 'tuple']; 2 | -------------------------------------------------------------------------------- /src/utils/executeGetMatrix.ts: -------------------------------------------------------------------------------- 1 | import { KernelMessage } from '@jupyterlab/services'; 2 | import { NotebookPanel } from '@jupyterlab/notebook'; 3 | import { getMatrix } from '../python_code/getMatrix'; 4 | 5 | export const executeMatrixContent = async ( 6 | varName: string, 7 | varStartColumn: number, 8 | varEndColumn: number, 9 | varStartRow: number, 10 | varEndRow: number, 11 | notebookPanel: NotebookPanel 12 | ): Promise => { 13 | if (!notebookPanel) { 14 | throw new Error('Kernel not available.'); 15 | } 16 | const code = getMatrix( 17 | varName, 18 | varStartRow, 19 | varEndRow, 20 | varStartColumn, 21 | varEndColumn 22 | ); 23 | 24 | return new Promise((resolve, reject) => { 25 | let outputData = ''; 26 | let resultResolved = false; 27 | const future = 28 | notebookPanel.sessionContext?.session?.kernel?.requestExecute({ 29 | code, 30 | store_history: false 31 | }); 32 | 33 | if (!future) { 34 | return reject(new Error('No future returned from kernel execution.')); 35 | } 36 | 37 | future.onIOPub = (msg: KernelMessage.IIOPubMessage) => { 38 | const msgType = msg.header.msg_type; 39 | 40 | if (msgType === 'execute_result' || msgType === 'display_data') { 41 | const content = msg.content as any; 42 | if (content.data && content.data['application/json']) { 43 | resultResolved = true; 44 | resolve(content.data['application/json']); 45 | } else if (content.data && content.data['text/plain']) { 46 | outputData += content.data['text/plain']; 47 | } 48 | } else if (msgType === 'stream') { 49 | /* empty */ 50 | } else if (msgType === 'error') { 51 | console.error('Python error:', msg.content); 52 | reject(new Error('Error during Python execution.')); 53 | } 54 | }; 55 | 56 | future.done.then(() => { 57 | if (!resultResolved) { 58 | try { 59 | const cleanedData = outputData.trim(); 60 | const parsed = JSON.parse(cleanedData); 61 | resolve(parsed); 62 | } catch (err) { 63 | reject(new Error('Failed to parse output from Python.')); 64 | } 65 | } 66 | }); 67 | }); 68 | }; 69 | -------------------------------------------------------------------------------- /src/utils/globalKernelTimeStamp.ts: -------------------------------------------------------------------------------- 1 | let lastIdleTimestamp: number | null = null; 2 | 3 | export function getLastIdleTimestamp(): number | null { 4 | return lastIdleTimestamp; 5 | } 6 | 7 | export function setLastIdleTimestamp(timestamp: number) { 8 | lastIdleTimestamp = timestamp; 9 | } 10 | -------------------------------------------------------------------------------- /src/utils/kernelOperationNotifier.ts: -------------------------------------------------------------------------------- 1 | import { Signal } from '@lumino/signaling'; 2 | 3 | export class KernelOperationNotifier { 4 | private _inProgressSidebar = false; 5 | private _inProgressPanel = false; 6 | 7 | readonly sidebarOperationChanged = new Signal(this); 8 | readonly panelOperationChanged = new Signal(this); 9 | 10 | set inProgressSidebar(value: boolean) { 11 | if (this._inProgressSidebar !== value) { 12 | this._inProgressSidebar = value; 13 | this.sidebarOperationChanged.emit(value); 14 | } 15 | } 16 | get inProgressSidebar(): boolean { 17 | return this._inProgressSidebar; 18 | } 19 | 20 | set inProgressPanel(value: boolean) { 21 | if (this._inProgressPanel !== value) { 22 | this._inProgressPanel = value; 23 | this.panelOperationChanged.emit(value); 24 | } 25 | } 26 | get inProgressPanel(): boolean { 27 | return this._inProgressPanel; 28 | } 29 | } 30 | 31 | export const kernelOperationNotifier = new KernelOperationNotifier(); 32 | 33 | export async function withIgnoredSidebarKernelUpdates( 34 | fn: () => Promise 35 | ): Promise { 36 | kernelOperationNotifier.inProgressSidebar = true; 37 | try { 38 | return await fn(); 39 | } finally { 40 | kernelOperationNotifier.inProgressSidebar = false; 41 | } 42 | } 43 | 44 | export async function withIgnoredPanelKernelUpdates( 45 | fn: () => Promise 46 | ): Promise { 47 | kernelOperationNotifier.inProgressPanel = true; 48 | try { 49 | return await fn(); 50 | } finally { 51 | kernelOperationNotifier.inProgressPanel = false; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/utils/utils.ts: -------------------------------------------------------------------------------- 1 | import { allowedTypes } from './allowedTypes'; 2 | 3 | export function transpose(matrix: T[][]): T[][] { 4 | return matrix[0].map((_, colIndex) => 5 | matrix.map((row: T[]) => row[colIndex]) 6 | ); 7 | } 8 | 9 | interface TransformedMatrix { 10 | data: any[][]; 11 | fixedRowCount: number; 12 | fixedColumnCount: number; 13 | } 14 | 15 | interface TransformedMatrix { 16 | data: any[][]; 17 | fixedRowCount: number; 18 | fixedColumnCount: number; 19 | } 20 | 21 | export function transformMatrixData( 22 | matrixData: any[], 23 | variableType: string, 24 | currentRow: number, 25 | currentColumn: number 26 | ): TransformedMatrix { 27 | let data2D: any[][] = []; 28 | if (matrixData.length > 0 && !Array.isArray(matrixData[0])) { 29 | data2D = (matrixData as any[]).map(item => [item]); 30 | } else { 31 | data2D = matrixData as any[][]; 32 | } 33 | 34 | let data: any[][] = data2D; 35 | let fixedRowCount = 0; 36 | let fixedColumnCount = 0; 37 | 38 | if (data2D.length > 0 && allowedTypes.includes(variableType)) { 39 | const globalRowStart = currentRow; 40 | const headerRow = ['index']; 41 | const headerLength = 42 | variableType === 'DataFrame' ? data2D[0].length - 1 : data2D[0].length; 43 | for (let j = 0; j < headerLength; j++) { 44 | headerRow.push((globalRowStart + j).toString()); 45 | } 46 | 47 | let newData = [headerRow]; 48 | for (let i = 0; i < data2D.length; i++) { 49 | if (variableType === 'DataFrame') { 50 | newData.push([...data2D[i]]); 51 | } else { 52 | const globalIndex = currentRow + i; 53 | newData.push([globalIndex, ...data2D[i]]); 54 | } 55 | } 56 | 57 | if (variableType === 'DataFrame' || variableType === 'Series') { 58 | newData = transpose(newData); 59 | } 60 | 61 | data2D = transpose(data2D); 62 | data = newData; 63 | fixedRowCount = 1; 64 | fixedColumnCount = 1; 65 | } 66 | 67 | return { data, fixedRowCount, fixedColumnCount }; 68 | } 69 | -------------------------------------------------------------------------------- /src/watchers/notebookWatcher.ts: -------------------------------------------------------------------------------- 1 | import { JupyterFrontEnd } from '@jupyterlab/application'; 2 | import { Notebook } from '@jupyterlab/notebook'; 3 | import { Widget } from '@lumino/widgets'; 4 | import { Signal } from '@lumino/signaling'; 5 | import { DocumentWidget } from '@jupyterlab/docregistry'; 6 | import { NotebookPanel } from '@jupyterlab/notebook'; 7 | 8 | function getNotebook(widget: Widget | null): Notebook | null { 9 | if (!(widget instanceof DocumentWidget)) { 10 | return null; 11 | } 12 | 13 | const { content } = widget; 14 | if (!(content instanceof Notebook)) { 15 | return null; 16 | } 17 | 18 | return content; 19 | } 20 | 21 | export class NotebookWatcher { 22 | constructor(shell: JupyterFrontEnd.IShell) { 23 | this._shell = shell; 24 | this._shell.currentChanged?.connect((sender, args) => { 25 | this._mainAreaWidget = args.newValue; 26 | if (this._mainAreaWidget instanceof DocumentWidget) { 27 | this._notebookPanel = this.notebookPanel(); 28 | this._notebookPanelChanged.emit(this._notebookPanel); 29 | this._attachKernelChangeHandler(); 30 | } 31 | }); 32 | } 33 | 34 | get notebookPanelChanged(): Signal { 35 | return this._notebookPanelChanged; 36 | } 37 | 38 | get kernelInfo(): KernelInfo | null { 39 | return this._kernelInfo; 40 | } 41 | 42 | get kernelChanged(): Signal { 43 | return this._kernelChanged; 44 | } 45 | 46 | notebookPanel(): NotebookPanel | null { 47 | const notebook = getNotebook(this._mainAreaWidget); 48 | if (!notebook) { 49 | return null; 50 | } 51 | return notebook.parent instanceof NotebookPanel ? notebook.parent : null; 52 | } 53 | 54 | private _attachKernelChangeHandler(): void { 55 | if (this._notebookPanel) { 56 | const session = this._notebookPanel.sessionContext.session; 57 | 58 | if (session) { 59 | session.kernelChanged.connect(this._onKernelChanged, this); 60 | this._updateKernelInfo(session.kernel); 61 | } else { 62 | setTimeout(() => { 63 | const delayedSession = this._notebookPanel?.sessionContext.session; 64 | if (delayedSession) { 65 | delayedSession.kernelChanged.connect(this._onKernelChanged, this); 66 | this._updateKernelInfo(delayedSession.kernel); 67 | } else { 68 | console.warn('Session not initialized after delay'); 69 | } 70 | }, 2000); 71 | } 72 | } else { 73 | // console.warn('Session not initalizated'); 74 | } 75 | } 76 | 77 | private _onKernelChanged( 78 | sender: any, 79 | args: { name: string; oldValue: any; newValue: any } 80 | ): void { 81 | if (args.newValue) { 82 | this._updateKernelInfo(args.newValue); 83 | } else { 84 | this._kernelInfo = null; 85 | this._kernelChanged.emit(null); 86 | } 87 | } 88 | 89 | private _updateKernelInfo(kernel: any): void { 90 | this._kernelInfo = { 91 | name: kernel.name, 92 | id: kernel.id 93 | }; 94 | this._kernelChanged.emit(this._kernelInfo); 95 | } 96 | 97 | protected _kernelInfo: KernelInfo | null = null; 98 | protected _kernelChanged = new Signal(this); 99 | protected _shell: JupyterFrontEnd.IShell; 100 | protected _mainAreaWidget: Widget | null = null; 101 | protected _notebookPanel: NotebookPanel | null = null; 102 | protected _notebookPanelChanged = new Signal( 103 | this 104 | ); 105 | } 106 | 107 | export type KernelInfo = { 108 | name: string; 109 | id: string; 110 | }; 111 | -------------------------------------------------------------------------------- /style/base.css: -------------------------------------------------------------------------------- 1 | .mljar-variable-inspector-sidebar-widget { 2 | background-color: #ffffff; 3 | padding: 10px; 4 | font-family: 'Courier New', Courier, monospace; 5 | } 6 | 7 | .mljar-variable-inspector-sidebar-container { 8 | display: flex; 9 | flex-direction: column; 10 | height: 100%; 11 | overflow-y: auto; 12 | } 13 | 14 | .mljar-variable-inspector-list-container { 15 | flex: 1; 16 | overflow-y: hidden; 17 | /* padding-right: 10px; */ 18 | } 19 | 20 | .mljar-variable-inspector-list-container::-webkit-scrollbar { 21 | width: 8px; 22 | } 23 | 24 | .mljar-variable-inspector-list-container::-webkit-scrollbar-thumb { 25 | background-color: rgba(0, 0, 0, 0.2); 26 | border-radius: 4px; 27 | } 28 | 29 | .mljar-variable-inspector-list-container::-webkit-scrollbar-track { 30 | background-color: rgba(0, 0, 0, 0.05); 31 | } 32 | 33 | .mljar-variable-inspector-container { 34 | display: flex; 35 | flex-direction: column; 36 | height: 100%; 37 | } 38 | 39 | .mljar-variable-header-container { 40 | display: flex; 41 | justify-content: space-between; 42 | align-items: flex-end; 43 | margin-bottom: 8px; 44 | /* margin-right: 8px; */ 45 | border-bottom: 2px solid #ddd; 46 | } 47 | 48 | .mljar-variable-header { 49 | flex: 4; 50 | font-size: 0.85rem; 51 | font-weight: 700; 52 | color: var(--jp-ui-font-color1); 53 | text-align: left; 54 | padding-bottom: 8px; 55 | margin: 0; 56 | } 57 | 58 | .mljar-variable-inspector-header-list { 59 | display: grid; 60 | grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); 61 | align-items: center; 62 | font-size: 0.85rem; 63 | column-gap: 1rem; 64 | padding: 10px 8px; 65 | background-color: var(--jp-layout-color0); 66 | color: #0099cc; 67 | border: 1px solid #0099cc; 68 | border-top-right-radius: 5px; 69 | border-top-left-radius: 5px; 70 | font-weight: 800; 71 | } 72 | 73 | .mljar-variable-inspector-item { 74 | display: grid; 75 | grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); 76 | align-items: center; 77 | column-gap: 1rem; 78 | padding-left: 8px; 79 | padding-right: 8px; 80 | border-bottom: 1px solid var(--jp-border-color2); 81 | border-left: 1px solid var(--jp-border-color2); 82 | border-right: 1px solid var(--jp-border-color2); 83 | margin-bottom: 0px; 84 | margin-right: 0px; 85 | width: 100%; 86 | box-sizing: border-box; 87 | background-color: var(--jp-layout-color0); 88 | font-size: 0.7rem; 89 | box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); 90 | } 91 | 92 | .mljar-variable-inspector-item.small-value { 93 | min-height: 39px; 94 | } 95 | 96 | .mljar-variable-inspector-show-variable-button { 97 | background: none; 98 | position: relative; 99 | border: none; 100 | border-radius: 4px; 101 | cursor: pointer; 102 | padding: 4px; 103 | margin: 5px 0px; 104 | display: inline-block; 105 | width: 28px; 106 | align-items: center; 107 | justify-content: flex-start; 108 | color: #0099cc; 109 | transition: background-color 0.3s ease; 110 | } 111 | 112 | .mljar-variable-inspector-show-variable-button:disabled { 113 | opacity: 0.5; 114 | cursor: not-allowed; 115 | } 116 | 117 | .mljar-variable-inspector-list { 118 | list-style: none; 119 | padding: 0; 120 | margin: 0; 121 | } 122 | 123 | .mljar-variable-search-bar-container { 124 | margin: 0px 0px 10px 0px; 125 | } 126 | 127 | .mljar-variable-inspector-search-bar-input { 128 | width: 100%; 129 | padding: 8px; 130 | box-sizing: border-box; 131 | background-color: var(--jp-layout-color1); 132 | color: var(--jp-ui-font-color1); 133 | border: 1px solid var(--jp-border-color2); 134 | border-radius: 5px; 135 | } 136 | 137 | .mljar-variable-inspector-search-bar-input:focus { 138 | outline: none; 139 | border: 2px solid var(--jp-ui-font-color1); 140 | } 141 | 142 | .mljar-variable-inspector-search-bar-input::placeholder { 143 | color: var(--jp-ui-font-color2); 144 | } 145 | 146 | .mljar-variable-inspector-variable-name { 147 | font-weight: 600; 148 | } 149 | 150 | .mljar-variable-inspector-item:hover { 151 | background-color: var(--jp-layout-color2); 152 | cursor: pointer; 153 | } 154 | 155 | .mljar-variable-inspector-item.active { 156 | background-color: var(--jp-brand-color1); 157 | color: var(--jp-ui-inverse-font-color1); 158 | } 159 | 160 | .mljar-varable-item.active { 161 | background-color: var(--jp-brand-color1); 162 | color: var(--jp-ui-inverse-font-color1); 163 | } 164 | 165 | .mljar-variable-inspector-variable-name, 166 | .mljar-variable-type, 167 | .mljar-variable-inspector-variable-size, 168 | .mljar-variable-inspector-variable-value, 169 | .mljar-variable-shape { 170 | overflow: hidden; 171 | text-overflow: ellipsis; 172 | white-space: nowrap; 173 | } 174 | 175 | .mljar-variable-inspector-variable-size { 176 | word-spacing: -5px; 177 | } 178 | 179 | .mljar-variable-inspector-show-variable-button:hover { 180 | color: #fff; 181 | background-color: #0099cc; 182 | transition: background-color 0.3s ease; 183 | } 184 | 185 | .mljar-variable-detail-button-icon { 186 | display: flex; 187 | align-items: center; 188 | width: 20px; 189 | height: 20px; 190 | } 191 | 192 | .mljar-variable-inspector-skip-icon { 193 | display: flex; 194 | align-items: center; 195 | width: 15px; 196 | height: 15px; 197 | } 198 | 199 | .mljar-variable-inspector-settings-button, 200 | .mljar-variable-inspector-refresh-button { 201 | width: 30px; 202 | display: flex; 203 | margin: 2px 1px; 204 | align-items: center; 205 | justify-content: center; 206 | gap: 8px; 207 | color: #0099cc; 208 | border: none; 209 | border-radius: 4px; 210 | padding: 8px 0px; 211 | cursor: pointer; 212 | font-size: 0.75rem; 213 | transition: background-color 0.3s ease; 214 | } 215 | 216 | .mljar-variable-inspector-skip-button { 217 | display: flex; 218 | margin: 0px; 219 | align-items: center; 220 | justify-content: center; 221 | color: #0099cc; 222 | background-color: transparent; 223 | border: none; 224 | padding: 2px; 225 | border-radius: 4px; 226 | cursor: pointer; 227 | font-size: 0.75rem; 228 | transition: background-color 0.3s ease; 229 | } 230 | 231 | .mljar-variable-inspector-skip-button:disabled, 232 | .mljar-variable-inspector-settings-button:disabled, 233 | .mljar-variable-inspector-refresh-button:disabled { 234 | cursor: not-allowed; 235 | } 236 | 237 | .mljar-variable-inspector-skip-button:hover:not(:disabled), 238 | .mljar-variable-inspector-settings-button:hover:not(:disabled), 239 | .mljar-variable-inspector-refresh-button:hover:not(:disabled) { 240 | background-color: #0099cc; 241 | color: #ffffff; 242 | } 243 | 244 | .mljar-variable-inspector-refresh-button.manually-refresh { 245 | color: #28a745; 246 | } 247 | 248 | .mljar-variable-inspector-refresh-button.manually-refresh:hover:not(:disabled) { 249 | background-color: #28a745; 250 | color: #ffffff; 251 | } 252 | 253 | .mljar-variable-inspector-settings-button.active { 254 | background-color: #0099cc; 255 | color: #ffffff; 256 | } 257 | 258 | .mljar-variable-inspector-settings-icon, 259 | .mljar-variable-inspector-refresh-icon { 260 | display: flex; 261 | align-items: center; 262 | width: 15px; 263 | height: 15px; 264 | } 265 | 266 | .mljar-variable-inspector-message { 267 | margin: 10px 0px 0px 5px; 268 | font-size: small; 269 | } 270 | 271 | .mljar-variable-inspector-settings-container { 272 | position: relative; 273 | display: inline-block; 274 | } 275 | 276 | .mljar-variable-inspector-settings-menu { 277 | position: absolute; 278 | right: 0; 279 | top: 40px; 280 | width: 200px; 281 | background-color: var(--jp-layout-color0); 282 | border: 1px solid var(--jp-layout-color3); 283 | box-shadow: 0px 2px 24px 0px var(--jp-layout-color2); 284 | border-radius: 5px; 285 | z-index: 100; 286 | } 287 | 288 | .mljar-variable-inspector-settings-menu-list { 289 | list-style: none; 290 | margin: 0px; 291 | padding: 0px; 292 | } 293 | 294 | .mljar-variable-inspector-settings-menu-item { 295 | font-size: 12px; 296 | padding: 5px 10px; 297 | cursor: pointer; 298 | text-align: left; 299 | width: 100%; 300 | transition: background 0.3s ease; 301 | display: flex; 302 | justify-content: space-between; 303 | align-items: center; 304 | } 305 | 306 | .mljar-variable-inspector-settings-menu-item.first { 307 | border-top-left-radius: 5px; 308 | border-top-right-radius: 5px; 309 | } 310 | 311 | .mljar-variable-inspector-settings-menu-item.last { 312 | border-bottom-left-radius: 5px; 313 | border-bottom-right-radius: 5px; 314 | } 315 | 316 | .mljar-variable-inspector-settings-menu-item:hover { 317 | background-color: var(--jp-layout-color2); 318 | cursor: pointer; 319 | } 320 | 321 | .mljar-variable-actions-container { 322 | display: flex; 323 | gap: 10px; 324 | margin-bottom: 10px; 325 | margin-right: 10px; 326 | } 327 | 328 | .mljar-variable-inspector-sidebar-container::-webkit-scrollbar { 329 | width: 9px; 330 | height: 8px; 331 | } 332 | 333 | .mljar-variable-inspector-sidebar-container::-webkit-scrollbar-track { 334 | background: var(--jp-layout-color3); 335 | border-radius: 8px; 336 | } 337 | 338 | .mljar-variable-inspector-sidebar-container::-webkit-scrollbar-thumb { 339 | background-color: rgba(255, 255, 255, 0.6); 340 | border-radius: 8px; 341 | border: 2px solid transparent; 342 | background-clip: padding-box; 343 | } 344 | 345 | .mljar-variable-spinner { 346 | border: 4px solid rgba(0, 0, 0, 0.1); 347 | width: 10px; 348 | height: 10px; 349 | border-radius: 50%; 350 | border-left-color: #ffffff; 351 | animation: spin 1s linear infinite; 352 | } 353 | 354 | .mljar-variable-spinner-big { 355 | border: 4px solid rgba(0, 0, 0, 0.1); 356 | width: 20px; 357 | height: 20px; 358 | border-radius: 50%; 359 | border-left-color: #ffffff; 360 | animation: spin 1s linear infinite; 361 | } 362 | 363 | @keyframes spin { 364 | to { 365 | transform: rotate(360deg); 366 | } 367 | } 368 | 369 | .mljar-variable-inspector-pagination-container { 370 | padding: 8px; 371 | background-color: var(--jp-layout-color0); 372 | margin: auto; 373 | align-items: center; 374 | } 375 | 376 | .mljar-variable-inspector-pagination-item { 377 | display: flex; 378 | flex-direction: column; 379 | align-items: center; 380 | gap: 10px; 381 | } 382 | 383 | .mljar-variable-inspector-choose-range { 384 | display: flex; 385 | align-items: center; 386 | gap: 10px; 387 | font-size: 14px; 388 | } 389 | 390 | .mljar-variable-inspector-pagination-input { 391 | width: 60px; 392 | padding: 5px; 393 | text-align: center; 394 | border: 1px solid #ccc; 395 | border-radius: 4px; 396 | font-size: 14px; 397 | background-color: var(--jp-border-color2); 398 | } 399 | 400 | .mljar-variable-inspector-pagination-input:focus { 401 | outline: none; 402 | border-color: #007bff; 403 | box-shadow: 0 0 4px rgba(0, 123, 255, 0.5); 404 | } 405 | 406 | .mljar-variable-inspector-pagination-input::-webkit-outer-spin-button, 407 | .mljar-variable-inspector-pagination-input::-webkit-inner-spin-button { 408 | -webkit-appearance: none; 409 | margin: 0; 410 | } 411 | 412 | .ReactVirtualized__Grid::-webkit-scrollbar { 413 | width: 9px; 414 | height: 8px; 415 | } 416 | 417 | .ReactVirtualized__Grid::-webkit-scrollbar-track { 418 | background: var(--jp-layout-color3); 419 | border-radius: 8px; 420 | } 421 | 422 | .ReactVirtualized__Grid::-webkit-scrollbar-thumb { 423 | background-color: rgba(255, 255, 255, 0.6); 424 | border-radius: 8px; 425 | border: 2px solid transparent; 426 | background-clip: padding-box; 427 | } 428 | 429 | .mljar-variable-inspector-preview { 430 | cursor: pointer; 431 | white-space: nowrap; 432 | overflow: hidden; 433 | text-overflow: ellipsis; 434 | color: #1976d2; 435 | } 436 | 437 | .mljar-variable-inspector-preview:hover { 438 | text-decoration: underline; 439 | } 440 | 441 | .mljar-variable-inspector-item { 442 | cursor: pointer; 443 | } 444 | 445 | .mljar-variable-inspector-variable-preview { 446 | background: none; 447 | border: none; 448 | padding: 0; 449 | margin: 0; 450 | cursor: pointer; 451 | font-family: 'Courier New', Courier, monospace; 452 | font-size: 0.7rem; 453 | font-weight: bold; 454 | display: inline-block; 455 | max-width: 100%; 456 | white-space: nowrap; 457 | text-overflow: ellipsis; 458 | overflow: hidden; 459 | text-align: left; 460 | color: var(--jp-ui-font-color1); 461 | } 462 | 463 | .mljar-variable-inspector-variable-preview:hover { 464 | text-decoration: underline; 465 | background-color: #d3d3d3; 466 | } 467 | 468 | .mljar-variable-inspector-variable-preview, 469 | .mljar-variable-inspector-variable-value { 470 | padding-left: 7px; 471 | } -------------------------------------------------------------------------------- /style/index.css: -------------------------------------------------------------------------------- 1 | @import url('base.css'); 2 | -------------------------------------------------------------------------------- /style/index.js: -------------------------------------------------------------------------------- 1 | import './base.css'; 2 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "allowSyntheticDefaultImports": true, 4 | "composite": true, 5 | "declaration": true, 6 | "esModuleInterop": true, 7 | "incremental": true, 8 | "jsx": "react", 9 | "lib": ["DOM", "ES2018", "ES2020.Intl"], 10 | "module": "esnext", 11 | "moduleResolution": "node", 12 | "noEmitOnError": true, 13 | "noImplicitAny": true, 14 | "noUnusedLocals": true, 15 | "preserveWatchOutput": true, 16 | "resolveJsonModule": true, 17 | "outDir": "lib", 18 | "rootDir": "src", 19 | "strict": true, 20 | "strictNullChecks": true, 21 | "target": "ES2018", 22 | "skipLibCheck": true 23 | }, 24 | "include": ["src/**/*.ts", "src/**/*.tsx"], 25 | "exclude": ["node_modules", "lib"] 26 | } 27 | -------------------------------------------------------------------------------- /variable_inspector/__init__.py: -------------------------------------------------------------------------------- 1 | try: 2 | from ._version import __version__ 3 | except ImportError: 4 | import warnings 5 | warnings.warn("Importing 'variable_inspector' outside a proper installation.") 6 | __version__ = "dev" 7 | 8 | 9 | def _jupyter_labextension_paths(): 10 | return [{ 11 | "src": "labextension", 12 | "dest": "variable-inspector" 13 | }] 14 | --------------------------------------------------------------------------------