diff --git a/.coveragerc b/.coveragerc deleted file mode 100644 index 20e862ae2634cbec03b79dc8ead562f8625d2d48..0000000000000000000000000000000000000000 --- a/.coveragerc +++ /dev/null @@ -1,2 +0,0 @@ -[run] -omit = fileupload/tests/* diff --git a/.gitignore b/.gitignore index a4bfd17356dec7336f2c171451a05da58c08f837..c678a42a4dc30ee7487bde077b15956a69fa0530 100644 --- a/.gitignore +++ b/.gitignore @@ -145,15 +145,12 @@ $RECYCLE.BIN/ # ---- **/node_modules/ -fileupload/nbextension/static/index.* -fileupload/labextension/*.tgz +jsfileupload/nbextension/static/index.* +jsfileupload/labextension/*.tgz # Coverage data # ------------- **/coverage/ # Packed lab extensions -fileupload/labextension - -# vscode -.vscode/ +jsfileupload/labextension diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 0c39c6b315703392352646b7e74097f72cc87021..0000000000000000000000000000000000000000 --- a/.travis.yml +++ /dev/null @@ -1,74 +0,0 @@ -language: python -python: - - 3.7 - - 3.6 - - 3.5 -sudo: false -dist: xenial -services: - - xvfb -addons: - apt_packages: - - pandoc -env: - matrix: - - GROUP=python -matrix: - include: - - python: 3.5 - env: GROUP=js - include: - - python: 3.6 - env: GROUP=docs -cache: - pip: true - directories: - - node_modules # NPM packages - - $HOME/.npm -before_install: - - pip install -U pip setuptools - - nvm install 8 - - | - if [[ $GROUP == python ]]; then - pip install codecov - elif [[ $GROUP == js ]]; then - npm install -g codecov - fi -install: - - | - if [[ $GROUP == python ]]; then - pip install --upgrade ".[test]" -v - elif [[ $GROUP == js ]]; then - pip install --upgrade -e ".[test]" -v - elif [[ $GROUP == docs ]]; then - pip install --upgrade ".[test, examples, docs]" -v - fi -before_script: - # Set up a virtual screen for Firefox browser testing: - - | - if [[ $GROUP == js ]]; then - export CHROME_BIN=chromium-browser - fi - git config --global user.email travis@fake.com - git config --global user.name "Travis CI" -script: - - | - if [[ $GROUP == python ]]; then - EXIT_STATUS=0 - pushd $(mktemp -d) - py.test -l --cov-report xml:$TRAVIS_BUILD_DIR/coverage.xml --cov=fileupload --pyargs fileupload || EXIT_STATUS=$? - popd - (exit $EXIT_STATUS) - elif [[ $GROUP == js ]]; then - npm test - elif [[ $GROUP == docs ]]; then - EXIT_STATUS=0 - cd docs - make html || EXIT_STATUS=$? - make linkcheck || EXIT_STATUS=$? - cd .. - python -m pytest_check_links --links-ext=.md -o testpaths=. -o addopts= || EXIT_STATUS=$? - (exit $EXIT_STATUS) - fi -after_success: - - codecov diff --git a/LICENSE.txt b/LICENSE.txt index 99c418a74ea06fb099956389090d2afcb157869b..2fccb06f7cd95354c8f09b1d06195381886292f8 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,6 +1,8 @@ -Copyright (c) 2019 Alice Grosch +Copyright (c) 2020 Juelich Supercomputing Centre (JSC) All rights reserved. + Alice Grosch <a.grosch@fz-juelich.de> + Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff --git a/MANIFEST.in b/MANIFEST.in index a8dda9537a4dec5f4db07f33a083956291d1e548..d20a3e68670447b36e4c3a6f1fd31b8a9a66f60f 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -8,7 +8,7 @@ include .coverage.rc include tsconfig.json include package.json include webpack.config.js -include fileupload/labextension/*.tgz +include jsfileupload/labextension/*.tgz # Documentation graft docs @@ -25,7 +25,7 @@ graft tests prune tests/build # Javascript files -graft fileupload/nbextension +graft jsfileupload/nbextension graft src prune **/node_modules prune coverage diff --git a/README.md b/README.md index 2baf87af704d21fb01f29758ccd1653aa4d4ecff..76fe32221dbf051b2781ff29764746d4cb48c642 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,8 @@ -# fileupload -[](https://travis-ci.org/ksc/fileupload) -[](https://codecov.io/gh/ksc/fileupload) +# jsfileupload + +[](https://travis-ci.org//jsfileupload) +[](https://codecov.io/gh//jsfileupload) FileUpload Widget using the Jupyter Notebook Server API. @@ -11,22 +12,21 @@ FileUpload Widget using the Jupyter Notebook Server API. You can install using `pip`: ```bash -pip install fileupload +pip install jsfileupload ``` or from this GitLab directly ```bash -pip install git+https://gitlab.version.fz-juelich.de/jupyter4jsc/j4j_extras/fileupload.git -``` +pip install git+https://gitlab.version.fz-juelich.de/jupyter4jsc/j4j_extras/jsfileupload.git Or if you use jupyterlab: ```bash -pip install fileupload +pip install jsfileupload jupyter labextension install @jupyter-widgets/jupyterlab-manager ``` If you are using Jupyter Notebook 5.2 or earlier, you may also need to enable the nbextension: ```bash -jupyter nbextension enable --py [--sys-prefix|--user|--system] fileupload +jupyter nbextension enable --py [--sys-prefix|--user|--system] jsfileupload ``` diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 0782b69047f9a0dee1f0a352c6f83f597cab1e53..0000000000000000000000000000000000000000 --- a/appveyor.yml +++ /dev/null @@ -1,62 +0,0 @@ -# Do not build feature branch with open Pull Requests -skip_branch_with_pr: true - -# environment variables -environment: - nodejs_version: "8" - matrix: - - PYTHON: "C:\\Miniconda3-x64" - PYTHON_VERSION: "3.7" - PYTHON_MAJOR: 3 - PYTHON_ARCH: "64" - - PYTHON: "C:\\Miniconda3" - PYTHON_VERSION: "3.4" - PYTHON_MAJOR: 3 - PYTHON_ARCH: "32" - -# build cache to preserve files/folders between builds -cache: - - '%AppData%/npm-cache' - - '%PYTHON%/pkgs' - - '%LOCALAPPDATA%\pip\Cache' - -# scripts that run after cloning repository -install: - # Install node: - - ps: Install-Product node $env:nodejs_version - # Ensure python scripts are from right version: - - 'SET "PATH=%PYTHON%\Scripts;%PYTHON%;%PATH%"' - # Setup conda: - - 'conda list' - - 'conda update conda -y' - # If 32 bit, force conda to use it: - - 'IF %PYTHON_ARCH% EQU 32 SET CONDA_FORCE_32BIT=1' - - 'conda create -n test_env python=%PYTHON_VERSION% -y' - - 'activate test_env' - # Update install tools: - - 'conda install setuptools pip -y' - - 'python -m pip install --upgrade pip' - - 'python -m easy_install --upgrade setuptools' - # Install coverage utilities: - - 'pip install codecov' - # Install our package: - - 'pip install --upgrade ".[test]" -v' - -build: off - -# scripts to run before tests -before_test: - - git config --global user.email appveyor@fake.com - - git config --global user.name "AppVeyor CI" - - set "tmptestdir=%tmp%\fileupload-%RANDOM%" - - mkdir "%tmptestdir%" - - cd "%tmptestdir%" - - -# to run your custom scripts instead of automatic tests -test_script: - - 'py.test -l --cov-report xml:"%APPVEYOR_BUILD_FOLDER%\coverage.xml" --cov=fileupload --pyargs fileupload' - -on_success: - - cd "%APPVEYOR_BUILD_FOLDER%" - - codecov -X gcov --file "%APPVEYOR_BUILD_FOLDER%\coverage.xml" diff --git a/codecov.yml b/codecov.yml deleted file mode 100644 index 6d69c42a8b173ef1852cee6941a97f43b74acbb3..0000000000000000000000000000000000000000 --- a/codecov.yml +++ /dev/null @@ -1,12 +0,0 @@ -comment: off -# show coverage in CI status, but never consider it a failure -coverage: - status: - project: - default: - target: 0% - patch: - default: - target: 0% -ignore: - - "fileupload/tests" diff --git a/css/widget.css b/css/widget.css deleted file mode 100644 index 98542cecf9ab63028d2c09ede16d2c69d9878f0e..0000000000000000000000000000000000000000 --- a/css/widget.css +++ /dev/null @@ -1,3 +0,0 @@ -.custom-widget { - background-color: blue; -} diff --git a/docs/Makefile b/docs/Makefile index db46c3c75c91babbb464a471640485e72fe1ac1f..8698a6223488158a9d66f9c0dc7aa030f32b0f3a 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -4,7 +4,7 @@ # You can set these variables from the command line. SPHINXOPTS = SPHINXBUILD = sphinx-build -SPHINXPROJ = fileupload +SPHINXPROJ = jsfileupload SOURCEDIR = source BUILDDIR = build diff --git a/docs/environment.yml b/docs/environment.yml index 1f0cc8946260a55e54f2cf926fc1e54cc669dd77..c07600598c05a0892112dfdc64d37e3d25927d4f 100644 --- a/docs/environment.yml +++ b/docs/environment.yml @@ -1,5 +1,5 @@ -name: fileupload_docs +name: jsfileupload_docs channels: - conda-forge dependencies: diff --git a/docs/make.bat b/docs/make.bat index ff644ec07431262d44f41d6f0c69b226c4c1a0f6..42b7e948b593222a5beb69ba77b96a7467c135a0 100644 --- a/docs/make.bat +++ b/docs/make.bat @@ -9,7 +9,7 @@ if "%SPHINXBUILD%" == "" ( ) set SOURCEDIR=source set BUILDDIR=build -set SPHINXPROJ=fileupload +set SPHINXPROJ=jsfileupload if "%1" == "" goto help diff --git a/docs/source/conf.py b/docs/source/conf.py index 2eaf56868f348b7988a73718fae4fd165d238489..4b7b123e6deb9d70cfc23487cc24e26b2a13a335 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# fileupload documentation build configuration file +# jsfileupload documentation build configuration file # # This file is execfile()d with the current directory set to its # containing dir. @@ -54,9 +54,9 @@ source_suffix = '.rst' master_doc = 'index' # General information about the project. -project = 'fileupload' -copyright = '2019, Alice Grosch' -author = 'Alice Grosch' +project = 'jsfileupload' +copyright = '2020, Juelich Supercomputing Centre (JSC)' +author = 'Juelich Supercomputing Centre (JSC)' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the @@ -69,7 +69,7 @@ author = 'Alice Grosch' import os here = os.path.dirname(__file__) repo = os.path.join(here, '..', '..') -_version_py = os.path.join(repo, 'fileupload', '_version.py') +_version_py = os.path.join(repo, 'jsfileupload', '_version.py') version_ns = {} with open(_version_py) as f: exec(f.read(), version_ns) @@ -116,7 +116,7 @@ html_static_path = ['_static'] # -- Options for HTMLHelp output ------------------------------------------ # Output file base name for HTML help builder. -htmlhelp_basename = 'fileuploaddoc' +htmlhelp_basename = 'jsfileuploaddoc' # -- Options for LaTeX output --------------------------------------------- @@ -143,8 +143,8 @@ latex_elements = { # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). latex_documents = [ - (master_doc, 'fileupload.tex', 'fileupload Documentation', - 'Alice Grosch', 'manual'), + (master_doc, 'jsfileupload.tex', 'jsfileupload Documentation', + 'Juelich Supercomputing Centre (JSC)', 'manual'), ] @@ -154,8 +154,8 @@ latex_documents = [ # (source start file, name, description, authors, manual section). man_pages = [ (master_doc, - 'fileupload', - 'fileupload Documentation', + 'jsfileupload', + 'jsfileupload Documentation', [author], 1) ] @@ -167,10 +167,10 @@ man_pages = [ # dir menu entry, description, category) texinfo_documents = [ (master_doc, - 'fileupload', - 'fileupload Documentation', + 'jsfileupload', + 'jsfileupload Documentation', author, - 'fileupload', + 'jsfileupload', 'FileUpload Widget using the Jupyter Notebook Server API.', 'Miscellaneous'), ] diff --git a/docs/source/develop-install.rst b/docs/source/develop-install.rst index 2d3d7929a23f6a89cfea1845c9c263269d864404..8218c47f7cabfcc1f321856c72fafeebd017e209 100644 --- a/docs/source/develop-install.rst +++ b/docs/source/develop-install.rst @@ -3,11 +3,11 @@ Developer install ================= -To install a developer version of fileupload, you will first need to clone +To install a developer version of jsfileupload, you will first need to clone the repository:: - git clone https://github.com/ksc/fileupload - cd fileupload + git clone https://github.com//jsfileupload + cd jsfileupload Next, install it with a develop install using pip:: @@ -17,9 +17,9 @@ Next, install it with a develop install using pip:: If you are planning on working on the JS/frontend code, you should also do a link installation of the extension:: - jupyter nbextension install [--sys-prefix / --user / --system] --symlink --py fileupload + jupyter nbextension install [--sys-prefix / --user / --system] --symlink --py jsfileupload - jupyter nbextension enable [--sys-prefix / --user / --system] --py fileupload + jupyter nbextension enable [--sys-prefix / --user / --system] --py jsfileupload with the `appropriate flag`_. Or, if you are using Jupyterlab:: diff --git a/docs/source/index.rst b/docs/source/index.rst index 586895014cbc7cf6be90380783a374d12a6bf444..d9285ffbfccad8349363b891b480f98e52dab603 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -1,5 +1,5 @@ -fileupload +jsfileupload ===================================== Version: |release| @@ -10,13 +10,13 @@ FileUpload Widget using the Jupyter Notebook Server API. Quickstart ---------- -To get started with fileupload, install with pip:: +To get started with jsfileupload, install with pip:: - pip install fileupload + pip install jsfileupload or with conda:: - conda install fileupload + conda install jsfileupload Contents diff --git a/docs/source/installing.rst b/docs/source/installing.rst index f96ca25028b9b1fa8444cda59b2f517d54888381..cd9e9767da6f1660ee3f1fb64e02ca63f582cb87 100644 --- a/docs/source/installing.rst +++ b/docs/source/installing.rst @@ -5,27 +5,27 @@ Installation ============ -The simplest way to install fileupload is via pip:: +The simplest way to install jsfileupload is via pip:: - pip install fileupload + pip install jsfileupload or via conda:: - conda install fileupload + conda install jsfileupload If you installed via pip, and notebook version < 5.3, you will also have to install / configure the front-end extension as well. If you are using classic notebook (as opposed to Jupyterlab), run:: - jupyter nbextension install [--sys-prefix / --user / --system] --py fileupload + jupyter nbextension install [--sys-prefix / --user / --system] --py jsfileupload - jupyter nbextension enable [--sys-prefix / --user / --system] --py fileupload + jupyter nbextension enable [--sys-prefix / --user / --system] --py jsfileupload with the `appropriate flag`_. If you are using Jupyterlab, install the extension with:: - jupyter labextension install fileupload + jupyter labextension install jsfileupload If you are installing using conda, these commands should be unnecessary, but If you need to run them the commands should be the same (just make sure you choose the diff --git a/examples/introduction.ipynb b/examples/introduction.ipynb index 3da86f72c4057f69835ce725d301ce7b2491d7cd..04c7433010b6986a73be5382b8ff42ce3f10b37e 100644 --- a/examples/introduction.ipynb +++ b/examples/introduction.ipynb @@ -13,7 +13,7 @@ "metadata": {}, "outputs": [], "source": [ - "import fileupload\n", + "import jsfileupload\n", "from ipywidgets import Output" ] }, @@ -21,38 +21,61 @@ "cell_type": "code", "execution_count": 2, "metadata": {}, + "outputs": [], + "source": [ + "# Upload to the examples subdirectory.\n", + "upload_url = 'http://localhost:8888/api/contents/examples/' \n", + "token = '<insert-your-token>'\n", + "\n", + "uploader = jsfileupload.FileUpload(upload_url=upload_url, \n", + " token=token, \n", + " multiple=True,\n", + " button_style='primary',\n", + " layout={'border':'solid blue 1px'})" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [], + "source": [ + "out = Output()\n", + "@out.capture()\n", + "def observe_responses(change):\n", + " print(\"Upload progress: {}\".format(change['owner'].responses))\n", + " \n", + "@out.capture()\n", + "def observe_finish(change):\n", + " print(\"Finished upload: {}\".format(change['owner'].finished))\n", + "\n", + "uploader.observe(observe_responses, 'responses')\n", + "uploader.observe(observe_finish, 'finished')" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "15eb9e5cfeb84c038183522fc1d7ec37", + "model_id": "b18cd48242c84a28bdccbea95a849e20", "version_major": 2, "version_minor": 0 }, "text/plain": [ - "FileUpload(value=None, button_style='primary', description='Upload', layout=Layout(width='200px'), multiple=Tr…" + "FileUpload(value=None, button_style='primary', description='Browse', layout=Layout(border='solid blue 1px'), m…" ] }, "metadata": {}, "output_type": "display_data" - } - ], - "source": [ - "uploader = fileupload.FileUpload(multiple=True, token='e9399d0955967baaa3e0f7364b7a0a80c9d5fda37f9e897f')\n", - "uploader.button_style = 'primary'\n", - "uploader.layout.width = '200px'\n", - "uploader" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [ + }, { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "9508a58788554a50817002dca74be858", + "model_id": "c1662b6ce67441f2832a7942f4af87f3", "version_major": 2, "version_minor": 0 }, @@ -65,25 +88,17 @@ } ], "source": [ - "out = Output()\n", - "@out.capture()\n", - "def observe_finish(change):\n", - " print(change['owner'].finished)\n", - "@out.capture()\n", - "def observe_responses(change):\n", - " print(change['owner'].responses)\n", - "uploader.observe(observe_finish, 'finished')\n", - "uploader.observe(observe_responses, 'responses')\n", - "\n", - "out" + "display(uploader)\n", + "display(out)" ] }, { "cell_type": "code", - "execution_count": 4, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ + "# Select some files to upload, then run\n", "uploader.upload()" ] } @@ -104,7 +119,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.6" + "version": "3.6.8" } }, "nbformat": 4, diff --git a/fileupload.json b/fileupload.json deleted file mode 100644 index 447061fe34f29714a26cad48184568fbde408b2c..0000000000000000000000000000000000000000 --- a/fileupload.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "load_extensions": { - "fileupload/extension": true - } -} diff --git a/fileupload/__init__.py b/fileupload/__init__.py deleted file mode 100644 index bd58651283a3b73fade048b77c0a41dd4a30b644..0000000000000000000000000000000000000000 --- a/fileupload/__init__.py +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env python -# coding: utf-8 - -# Copyright (c) Alice Grosch. -# Distributed under the terms of the Modified BSD License. - -from .widget_upload import FileUpload -from ._version import __version__, version_info - -from .nbextension import _jupyter_nbextension_paths diff --git a/fileupload/_frontend.py b/fileupload/_frontend.py deleted file mode 100644 index c107a8cddb170a063cbb72340ba087399c6b946d..0000000000000000000000000000000000000000 --- a/fileupload/_frontend.py +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env python -# coding: utf-8 - -# Copyright (c) Alice Grosch. -# Distributed under the terms of the Modified BSD License. - -""" -Information about the frontend package of the widgets. -""" - -module_name = "fileupload" -module_version = "^0.1.0" diff --git a/fileupload/_version.py b/fileupload/_version.py deleted file mode 100644 index bce0f989554364fecfe8c69ade8095e0306f119b..0000000000000000000000000000000000000000 --- a/fileupload/_version.py +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env python -# coding: utf-8 - -# Copyright (c) Alice Grosch. -# Distributed under the terms of the Modified BSD License. - -version_info = (0, 1, 0, 'dev') -__version__ = ".".join(map(str, version_info)) diff --git a/fileupload/nbextension/__init__.py b/fileupload/nbextension/__init__.py deleted file mode 100644 index 004f23d6ba1cf59e970113d254433b4f0f3bc214..0000000000000000000000000000000000000000 --- a/fileupload/nbextension/__init__.py +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env python -# coding: utf-8 - -# Copyright (c) Alice Grosch -# Distributed under the terms of the Modified BSD License. - -def _jupyter_nbextension_paths(): - return [{ - 'section': 'notebook', - 'src': 'nbextension/static', - 'dest': 'fileupload', - 'require': 'fileupload/extension' - }] diff --git a/fileupload/nbextension/static/extension.js b/fileupload/nbextension/static/extension.js deleted file mode 100644 index 512f2b72c32f3c042ee8516f289e3a6f45b208e1..0000000000000000000000000000000000000000 --- a/fileupload/nbextension/static/extension.js +++ /dev/null @@ -1,17 +0,0 @@ -// Entry point for the notebook bundle containing custom model definitions. -// -define(function() { - "use strict"; - - window['requirejs'].config({ - map: { - '*': { - 'fileupload': 'nbextensions/fileupload/index', - }, - } - }); - // Export the required load_ipython_extension function - return { - load_ipython_extension : function() {} - }; -}); diff --git a/fileupload/tests/__init__.py b/fileupload/tests/__init__.py deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/fileupload/tests/conftest.py b/fileupload/tests/conftest.py deleted file mode 100644 index 20a88fb1eeaae59526ed78035c1c08ca41aace60..0000000000000000000000000000000000000000 --- a/fileupload/tests/conftest.py +++ /dev/null @@ -1,54 +0,0 @@ -#!/usr/bin/env python -# coding: utf-8 - -# Copyright (c) Alice Grosch. -# Distributed under the terms of the Modified BSD License. - -import pytest - -from ipykernel.comm import Comm -from ipywidgets import Widget - -class MockComm(Comm): - """A mock Comm object. - - Can be used to inspect calls to Comm's open/send/close methods. - """ - comm_id = 'a-b-c-d' - kernel = 'Truthy' - - def __init__(self, *args, **kwargs): - self.log_open = [] - self.log_send = [] - self.log_close = [] - super(MockComm, self).__init__(*args, **kwargs) - - def open(self, *args, **kwargs): - self.log_open.append((args, kwargs)) - - def send(self, *args, **kwargs): - self.log_send.append((args, kwargs)) - - def close(self, *args, **kwargs): - self.log_close.append((args, kwargs)) - -_widget_attrs = {} -undefined = object() - - -@pytest.fixture -def mock_comm(): - _widget_attrs['_comm_default'] = getattr(Widget, '_comm_default', undefined) - Widget._comm_default = lambda self: MockComm() - _widget_attrs['_ipython_display_'] = Widget._ipython_display_ - def raise_not_implemented(*args, **kwargs): - raise NotImplementedError() - Widget._ipython_display_ = raise_not_implemented - - yield MockComm() - - for attr, value in _widget_attrs.items(): - if value is undefined: - delattr(Widget, attr) - else: - setattr(Widget, attr, value) diff --git a/fileupload/tests/test_example.py b/fileupload/tests/test_example.py deleted file mode 100644 index 49ce42dd844acccfa05e97eecca211df9d45ca98..0000000000000000000000000000000000000000 --- a/fileupload/tests/test_example.py +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env python -# coding: utf-8 - -# Copyright (c) Alice Grosch. -# Distributed under the terms of the Modified BSD License. - -import pytest - -from ..example import ExampleWidget - - -def test_example_creation_blank(): - w = ExampleWidget() - assert w.value == 'Hello World' diff --git a/fileupload/tests/test_nbextension_path.py b/fileupload/tests/test_nbextension_path.py deleted file mode 100644 index ade9cec4fc5a3c32eedaae53136e11b740546d0a..0000000000000000000000000000000000000000 --- a/fileupload/tests/test_nbextension_path.py +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env python -# coding: utf-8 - -# Copyright (c) Alice Grosch. -# Distributed under the terms of the Modified BSD License. - - -def test_nbextension_path(): - # Check that magic function can be imported from package root: - from fileupload import _jupyter_nbextension_paths - # Ensure that it can be called without incident: - path = _jupyter_nbextension_paths() - # Some sanity checks: - assert len(path) == 1 - assert isinstance(path[0], dict) diff --git a/fileupload/widget_upload.py b/fileupload/widget_upload.py deleted file mode 100644 index 7e97b43a920ada0daa0ae90ebce5385ec5c1db39..0000000000000000000000000000000000000000 --- a/fileupload/widget_upload.py +++ /dev/null @@ -1,65 +0,0 @@ -#!/usr/bin/env python -# coding: utf-8 - -# Copyright (c) Alice Grosch. -# Distributed under the terms of the Modified BSD License. - -""" -TODO: Add module docstring -""" -from ipywidgets import ValueWidget -from ipywidgets import register, widget_serialization -from ipywidgets.widgets.trait_types import InstanceDict -from ipywidgets.widgets.widget_button import ButtonStyle -from ipywidgets.widgets.widget_description import DescriptionWidget - -from traitlets import ( - default, Unicode, Dict, List, Int, Bool, Bytes, CaselessStrEnum -) -from ._frontend import module_name, module_version - - -class FileUpload(DescriptionWidget, ValueWidget): - """TODO: Add docstring here - """ - _model_name = Unicode('FileUploadModel').tag(sync=True) - _model_module = Unicode(module_name).tag(sync=True) - _model_module_version = Unicode(module_version).tag(sync=True) - _view_name = Unicode('FileUploadView').tag(sync=True) - _view_module = Unicode(module_name).tag(sync=True) - _view_module_version = Unicode(module_version).tag(sync=True) - - accept = Unicode(help='File types to accept, empty string for all').tag(sync=True) - multiple = Bool(help='If True, allow for multiple files upload').tag(sync=True) - disabled = Bool(help='Enable or disable button').tag(sync=True) - icon = Unicode('upload', help="Font-awesome icon name, without the 'fa-' prefix.").tag(sync=True) - button_style = CaselessStrEnum( - values=['primary', 'success', 'info', 'warning', 'danger', ''], default_value='', - help="""Use a predefined styling for the button.""").tag(sync=True) - style = InstanceDict(ButtonStyle).tag(sync=True, **widget_serialization) - metadata = List(Dict(), help='List of file metadata').tag(sync=True) - - # Needed for uploading using the Notebook Server RestAPI. - token = Unicode(help='Jupyter API token').tag(sync=True) - upload_url = Unicode('http://localhost:8888/api/contents/', - help='http(s)://notebook_url/api/contents/').tag(sync=True) - - # Variables set on the JavaScript side. - files = List().tag(sync=True) - responses = List([]).tag(sync=True) - finished = Bool(False).tag(sync=True) - _upload = Bool(False).tag(sync=True) - - - def __init__(self, upload_url='http://localhost:8888/api/contents/', token='', *args, **kwargs): - super(FileUpload, self).__init__(*args, **kwargs) - self.upload_url = upload_url - self.token = token - - @default('description') - def _default_description(self): - return 'Upload' - - # Calls javascript function to upload. - def upload(self): - self._upload = True \ No newline at end of file diff --git a/jsfileupload.json b/jsfileupload.json new file mode 100644 index 0000000000000000000000000000000000000000..90b0fbdc2a6258bed195d416b9a7336b63d0bca5 --- /dev/null +++ b/jsfileupload.json @@ -0,0 +1,5 @@ +{ + "load_extensions": { + "jsfileupload/extension": true + } +} diff --git a/jsfileupload/tests/test_example.py b/jsfileupload/tests/test_example.py index 112621d894159fbc262d03655c865e05d3cd6de6..db1fa71c91d6f5ce7b69f2ca98c54025a45992e1 100644 --- a/jsfileupload/tests/test_example.py +++ b/jsfileupload/tests/test_example.py @@ -6,9 +6,9 @@ import pytest -from ..example import ExampleWidget +from ..upload_widget import FileUpload def test_example_creation_blank(): - w = ExampleWidget() - assert w.value == 'Hello World' + w = FileUpload() + assert w.upload_url == 'http://localhost:8888/api/contents/' diff --git a/package.json b/package.json index 3e6c870e30e067748a5bb2a3d83b5f02b976ce20..bc1063c29ddc2f9aa21f2e5c38f6399d03552f59 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "fileupload", + "name": "jsfileupload", "version": "0.1.0", "description": "FileUpload Widget using the Jupyter Notebook Server API.", "keywords": [ @@ -13,31 +13,31 @@ "dist/*.js", "css/*.css" ], - "homepage": "https://github.com/ksc/fileupload", + "homepage": "https://gitlab.version.fz-juelich.de/jupyter4jsc/j4j_extras/fileupload/", "bugs": { - "url": "https://github.com/ksc/fileupload/issues" + "url": "https://gitlab.version.fz-juelich.de/jupyter4jsc/j4j_extras/jsfileupload/issues" }, "license": "BSD-3-Clause", "author": { - "name": "Alice Grosch", + "name": "Juelich Supercomputing Centre (JSC)", "email": "a.grosch@fz-juelich.de" }, "main": "lib/index.js", "types": "./lib/index.d.ts", "repository": { "type": "git", - "url": "https://github.com/ksc/fileupload" + "url": "https://gitlab.version.fz-juelich.de/jupyter4jsc/j4j_extras/fileupload/" }, "scripts": { "build": "npm run build:lib && npm run build:nbextension", - "build:labextension": "npm run clean:labextension && mkdirp fileupload/labextension && cd fileupload/labextension && npm pack ../..", + "build:labextension": "npm run clean:labextension && mkdirp jsfileupload/labextension && cd jsfileupload/labextension && npm pack ../..", "build:lib": "tsc", "build:nbextension": "webpack -p", "build:all": "npm run build:labextension && npm run build:nbextension", "clean": "npm run clean:lib && npm run clean:nbextension", "clean:lib": "rimraf lib", - "clean:labextension": "rimraf fileupload/labextension", - "clean:nbextension": "rimraf fileupload/nbextension/static/index.js", + "clean:labextension": "rimraf jsfileupload/labextension", + "clean:nbextension": "rimraf jsfileupload/nbextension/static/index.js", "prepack": "npm run build:lib", "test": "npm run test:firefox", "test:chrome": "karma start --browsers=Chrome tests/karma.conf.js", diff --git a/pytest.ini b/pytest.ini index 368ac53357d75edae09109efe57d73a06612d1d7..5cb4c412fa3663a190d2c2f5eae70c4246d8fccf 100644 --- a/pytest.ini +++ b/pytest.ini @@ -1,4 +1,4 @@ [pytest] -testpaths = fileupload/tests examples +testpaths = jsfileupload/tests examples norecursedirs = node_modules .ipynb_checkpoints addopts = --nbval --current-env diff --git a/setup.py b/setup.py index 89ab27c5d6727c35e5dbf44fc6d14fafdfdaff92..b873ccb4261b4881a3109ae044220f3c9b43f2b0 100644 --- a/setup.py +++ b/setup.py @@ -19,7 +19,7 @@ from setuptools import setup # The name of the project -name = 'fileupload' +name = 'jsfileupload' # Ensure a valid python version ensure_python('>=3.4') @@ -44,10 +44,10 @@ package_data_spec = { } data_files_spec = [ - ('share/jupyter/nbextensions/fileupload', + ('share/jupyter/nbextensions/jsfileupload', nb_path, '*.js*'), ('share/jupyter/lab/extensions', lab_path, '*.tgz'), - ('etc/jupyter/nbconfig/notebook.d' , HERE, 'fileupload.json') + ('etc/jupyter/nbconfig/notebook.d' , HERE, 'jsfileupload.json') ] @@ -66,9 +66,9 @@ setup_args = dict( scripts = glob(pjoin('scripts', '*')), cmdclass = cmdclass, packages = find_packages(), - author = 'Alice Grosch', + author = 'Juelich Supercomputing Centre (JSC)', author_email = 'a.grosch@fz-juelich.de', - url = 'https://github.com/ksc/fileupload', + url = 'https://github.com//jsfileupload', license = 'BSD', platforms = "Linux, Mac OS X, Windows", keywords = ['Jupyter', 'Widgets', 'IPython'], diff --git a/src/extension.ts b/src/extension.ts index 82a95b210272d258373bfe761e88208eb73bc10e..d71c28c3778794e7ddd4edd72347cd82deb7bafa 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -8,6 +8,6 @@ // Some static assets may be required by the custom widget javascript. The base // url for the notebook is not known at build time and is therefore computed // dynamically. -(window as any).__webpack_public_path__ = document.querySelector('body')!.getAttribute('data-base-url') + 'nbextensions/fileupload'; +(window as any).__webpack_public_path__ = document.querySelector('body')!.getAttribute('data-base-url') + 'nbextensions/jsfileupload'; export * from './index'; diff --git a/src/index.ts b/src/index.ts index 54535d2cdd7cddb820acaf036512b136569e513c..346c3eda5f07ab03180345dc474a89a162811cdd 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,4 @@ -// Copyright (c) Alice Grosch +// Copyright (c) Juelich Supercomputing Centre (JSC) // Distributed under the terms of the Modified BSD License. export * from './version'; diff --git a/src/plugin.ts b/src/plugin.ts index fc3e7d57208d10cd6db5ba0bc0f7ec854bbc2025..dc19c68fc5491a2a1522da827bd7c6a59ea85a50 100644 --- a/src/plugin.ts +++ b/src/plugin.ts @@ -1,4 +1,4 @@ -// Copyright (c) Alice Grosch +// Copyright (c) Juelich Supercomputing Centre (JSC) // Distributed under the terms of the Modified BSD License. import { @@ -19,7 +19,7 @@ import { MODULE_NAME, MODULE_VERSION } from './version'; -const EXTENSION_ID = 'fileupload:plugin'; +const EXTENSION_ID = 'jsfileupload:plugin'; /** * The example plugin. diff --git a/src/version.ts b/src/version.ts index d8fc73bb899053f46f735119db8a7c3f4b6e38fa..dd14cc6def1bc766516557fc3a7c10800c6d3e54 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1,4 +1,4 @@ -// Copyright (c) Alice Grosch +// Copyright (c) Juelich Supercomputing Centre (JSC) // Distributed under the terms of the Modified BSD License. const data = require('../package.json'); diff --git a/src/widget.ts b/src/widget.ts index 01a6a0a5dcf52f405b90c38ee967c9d28ccfe192..613e351d426f4a7cd3c01ce13e21b06508608b4a 100644 --- a/src/widget.ts +++ b/src/widget.ts @@ -1,4 +1,4 @@ -// Copyright (c) Alice Grosch +// Copyright (c) Juelich Supercomputing Centre (JSC) // Distributed under the terms of the Modified BSD License. import { @@ -9,8 +9,6 @@ import { MODULE_NAME, MODULE_VERSION } from './version'; -import '../css/widget.css' - import * as _ from 'underscore'; export @@ -250,4 +248,4 @@ class FileUploadView extends DOMWidgetView { warning: ['mod-warning'], danger: ['mod-danger'] }; -} +} \ No newline at end of file diff --git a/tests/src/index.spec.ts b/tests/src/index.spec.ts index efd598cd676aa9fa2c3b6003e7be2aed9a2b85d8..a389e6918b731cc616ea66a16dcecd462efcabf6 100644 --- a/tests/src/index.spec.ts +++ b/tests/src/index.spec.ts @@ -12,25 +12,25 @@ import { } from './utils.spec'; import { - ExampleModel, ExampleView + FileUploadModel, FileUploadView } from '../../src/' -describe('Example', () => { +describe('FileUpload', () => { - describe('ExampleModel', () => { + describe('FileUploadModel', () => { it('should be createable', () => { - let model = createTestModel(ExampleModel); - expect(model).to.be.an(ExampleModel); - expect(model.get('value')).to.be('Hello World'); + let model = createTestModel(FileUploadModel); + expect(model).to.be.an(FileUploadModel); + expect(model.get('upload_url')).to.be('http://localhost:8888/api/contents/'); }); it('should be createable with a value', () => { - let state = { value: 'Foo Bar!' } - let model = createTestModel(ExampleModel, state); - expect(model).to.be.an(ExampleModel); - expect(model.get('value')).to.be('Foo Bar!'); + let state = { upload_url: 'Foo Bar!' } + let model = createTestModel(FileUploadModel, state); + expect(model).to.be.an(FileUploadModel); + expect(model.get('upload_url')).to.be('Foo Bar!'); }); }); diff --git a/tsconfig.json b/tsconfig.json index fe2bf59d66e55c8471307740092b0ae5e6a400c0..573496c34e55ed97f1131e32b3e72f00bcf6f31d 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -14,7 +14,7 @@ "sourceMap": true, "strict": false, "target": "es2015" -}, + }, "include": [ "src/**/*.ts", "src/**/*.tsx", diff --git a/webpack.config.js b/webpack.config.js index 89684eb2a5c2c4b696d5e15c5914b430d7b85f2e..90e1c521383dc202bae260e742345c18f47c86fc 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -27,7 +27,7 @@ module.exports = [ entry: './src/extension.ts', output: { filename: 'index.js', - path: path.resolve(__dirname, 'fileupload', 'nbextension', 'static'), + path: path.resolve(__dirname, 'jsfileupload', 'nbextension', 'static'), libraryTarget: 'amd' }, module: { @@ -39,7 +39,7 @@ module.exports = [ }, /** - * Embeddable fileupload bundle + * Embeddable jsfileupload bundle * * This bundle is almost identical to the notebook extension bundle. The only * difference is in the configuration of the webpack public path for the @@ -54,8 +54,8 @@ module.exports = [ filename: 'index.js', path: path.resolve(__dirname, 'dist'), libraryTarget: 'amd', - library: "fileupload", - publicPath: 'https://unpkg.com/fileupload@' + version + '/dist/' + library: "jsfileupload", + publicPath: 'https://unpkg.com/jsfileupload@' + version + '/dist/' }, devtool: 'source-map', module: { @@ -76,7 +76,7 @@ module.exports = [ output: { filename: 'embed-bundle.js', path: path.resolve(__dirname, 'docs', 'source', '_static'), - library: "fileupload", + library: "jsfileupload", libraryTarget: 'amd' }, module: {