Giter Site home page Giter Site logo

osscar-org / widget-code-input Goto Github PK

View Code? Open in Web Editor NEW
7.0 2.0 5.0 1.09 MB

A jupyter widget to allow input of a python function, with syntax highlighting

License: Other

JavaScript 40.15% CSS 0.94% Python 46.88% Jupyter Notebook 12.03%
jupyter widget jupyter-widget jupyter-widgets jupyter-labextension jupyterlab

widget-code-input's Introduction

widget-code-input

PyPI version Binder widget test screenshot comparison

A widget to allow input of a python function, with syntax highlighting.

Installation

You can install using pip:

pip install widget_code_input

Releasing and publishing a new version

In order to make a new release of the library and publish to PYPI, run

bumpver update --major/--minor/--patch

This will

  • update version numbers, make a corresponding git commit and a git tag;
  • push this commit and tag to Github, which triggers the Github Action that makes a new Github Release and publishes the package to PYPI.

Github workflow testing

widget test

If the widget test fails, it indicates there is something wrong with the code, and the widget is NOT being displayed correctly in the test.

screenshot comparison

If the widget test passes but the screenshot comparison fails, it indicates the appearance of the widget is different from the previous version. In this case, you'll need to manually download the artifact from the widget test and use it to replace the widget-sample.png figure in the test folder.

Acknowledgements

We acknowledge support from the EPFL Open Science Fund via the OSSCAR project.

widget-code-input's People

Contributors

dou-du avatar taylor-96 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

widget-code-input's Issues

Support for jupyterlab 2.x

Hi!

Does this widget support jupyterlab 2.x?
I'm planning to move Noto to JL 2.

Best regards,
Pierre-Olivier

No error traceback of code input

The error traceback does not go into the code input. Compare the error message of these two functions in the image, one time defined in a code input and one time in a usual way.

from widget_code_input import WidgetCodeInput

code_input = WidgetCodeInput(
        function_name="foo", 
        function_parameters="",
        docstring="""
""",
        function_body="""
return a
"""
)
code_input.get_function_object()()
def foo():
    return a
foo()

Basically you don't know in which line the error happens in the code widget.
code_input-no_traceback_error

multiple calls to IPython.display() renders CodeInput in wrong cell

Hello everyone,

When we display(codeinput) multiple times, the content of the WidgetCodeInput is rendered only on the output of the first display() call, and the following calls yield blank boxes.
image

The expected behaviour would be to have two separate renderings of the same Widget connected to the same backend View, according to the ipywidgets doc. This happens without problem for standard ipywidget Widgets.

My impression after reading this bit about WidgetModels is that the Typescript back-end object has trouble identifying which one of the WidgetView is trying to render the WidgetModel.

I am using Safari/Firefox and
widget_code_input : 3.5.5
IPython : 8.3.0
ipykernel : 6.9.1
ipywidgets : 8.0.3
jupyter_client : 7.2.2
jupyter_core : 4.11.1
jupyter_server : 1.18.1
jupyterlab : 3.4.8
nbclient : 0.5.13
nbconvert : 6.4.4
nbformat : 5.3.0
notebook : 6.4.11
qtconsole : 5.3.1
traitlets : 5.3.0
ipywidgets : 8.0.3

Code to reproduce :

#first cell

from widget_code_input import WidgetCodeInput

codeinput = WidgetCodeInput(
        function_name="foo", 
        function_parameters="",
        docstring=""" """,
        function_body="""

return True
"""
        )

display(codeinput)
# second cell 
display(codeinput)

Thank you very much for the help,

João

Issue setting uniqueID

Need to figure out how to have the uniqueID count persist when several instances of the widget are instantiated in a single notebook (currently there is an issue if >1 instance is created). _.uniqueID appears to reset to 1 each time.

string causes problem with the widget

def my_function():
    return 'test'

When input string into the widget, it keeps throwing out errors. It seems related to quotation mark.
More detailed investigate needs to be done.

Binder example too slow to open

I've been waiting >15 minutes (15!!) to open the projectile example in binder, and binder is still building the container!

I think that

  • we should keep the requirements.txt to a very minimal set (e.g. do we really ned to depend on jupyterlab to use this widget? If not, jupyterlab should not be in the requirements.txt; you can create a optional-requirements.txt or something like this in case)
  • we should make sure the example/demos have very minimal dependencies. I think this is achieved by only keeping the very minimal required dependencies in requirements.txt. Otherwise let's discuss.

But I think it critical that demos open super quick, otherwise nobody will ever see them if they take more than 1 min to open.
@dou-du could you check the requirements and limit to really required ones? Thanks!

(Also check this comment)

Widget view is not updated on trait change

If one of the traits of a CodeInputWidget instance is changed, the values are changed but the displayed widget is not updated. I assume that somewhere the traits are not correctly linked? Here is a small example

from widget_code_input import CodeInputWidget
wci = CodeInputWidget(function_name="foo", function_body="return 5")
wci

Then in another cell

wci.function_body = "return 6"

But the displayed function_body does not change. It is however registered as trait.

Intended use case?

I like the idea of Code input widget, but I am still not sure why it is just limited to a function. Can it be extended to a general input if we subclass it?

pip install fail

Hi Giovanni,

I can't seem to install through pip this widget using python 3.6. I did not try with other versions.
Here is the error message I get:

Could not find a version that satisfies the requirement widget_code_input (from versions: )
No matching distribution found for widget_code_input

Otherwise I can install the repo but it seems that the requirements are not properly read.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.