spyre icon indicating copy to clipboard operation
spyre copied to clipboard

Not compatible with Jupyter Notebook?

Open Dana-Farber opened this issue 7 years ago • 1 comments

Creating your @dataspyre hello-world app in a JupyterNotebook cell raises an error, @adamhajari :

Same exact code outside of jupyter works just fine. 😮

from spyre import server

class SimpleApp(server.App):
    title = "Simple App"
    inputs = [{
        "type": "text",
        "key": "words",
        "label": "write words here",
        "value": "hello world", 
        "action_id": "simple_html_output"
    }]

    outputs = [{
        "type": "html",
        "id": "simple_html_output"
    }]

    def getHTML(self, params):
        words = params["words"]
        return "Here's what you wrote in the textbox: <b>%s</b>" % words

app = SimpleApp()

app.launch()

error:

     20         self.JS_PATH = os.path.join(self.ROOT_DIR, 'public', 'js')
     21         self.CSS_PATH = os.path.join(self.ROOT_DIR, 'public', 'css')
---> 22         self.APP_PATH = os.path.dirname(os.path.realpath(__main__.__file__))
     23 
     24     def getHTML(self):

AttributeError: 'module' object has no attribute '__file__'

Can you help me figure out how to overcome this? Thanks!

import sys; sys.version
'2.7.14 |Anaconda custom (64-bit)| (default, Oct  5 2017, 02:28:52) \n[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)]'

jupyter notebook --version
5.0.0

Dana-Farber avatar Feb 01 '18 13:02 Dana-Farber

I get the same error! Could you fix it?

Morarin1 avatar Mar 12 '22 16:03 Morarin1