Code Monkey home page Code Monkey logo

nwb-web-gui's Introduction

NWB Web GUI

PyPI version

Web graphical user interface for NWB conversion and visualization.

1. Installation

From PyPI:

$ pip install nwb-web-gui

From a local copy of the repository:

$ git clone https://github.com/catalystneuro/nwb-web-gui.git
$ cd nwb-web-gui
$ pip install .

2. Running

From command line shortcut:

$ nwbgui

From repository local copy:

$ python wsgi.py

NWB Web GUI by default runs on localhost:5000.

3. Running on docker container (referencing a local folder)

  • Change on config.ini file the NWB_GUI_ROOT_PATH to /usr/src/nwb_web_gui/files
  • build docker with:
$ docker build -t latest .
  • run the docker with:
$ docker run -it -p 5000:5000 -p 8866:8866 -v /host/path/to/filesFolder:/usr/src/nwb_web_gui/files <image_id>

4. Run NWB Web GUI for a specific NWB Converter

NWB Web GUI can be set to run with any specific NWB converter:

from nwb_web_gui import init_app
import os


# Set ENV variables for app
# Set root path from where to run the GUI
data_path = '/source_path'
os.environ['NWB_GUI_ROOT_PATH'] = data_path

# Set which NWB GUI pages should be displayed
os.environ['NWB_GUI_RENDER_CONVERTER'] = 'True'
os.environ['NWB_GUI_RENDER_VIEWER'] = 'True'
os.environ['NWB_GUI_RENDER_DASHBOARD'] = 'False'

# Choose NWB converter to be used
os.environ['NWB_GUI_NWB_CONVERTER_MODULE'] = 'my_lab_to_nwb'
os.environ['NWB_GUI_NWB_CONVERTER_CLASS'] = 'MylabNWBConverter'

# Choose port where the GUI will run. Default is 5000
port = 5000

print(f'NWB GUI running on localhost:{port}')
print(f'Data path: {data_path}')

# Initialize app
app = init_app()

# Run app
app.run(
    host='0.0.0.0',
    port=port,
    debug=False,
    use_reloader=False
)

5. Documentation

Documentation

nwb-web-gui's People

Contributors

bendichter avatar luiztauffer avatar vinicvaz avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

nwb-web-gui's Issues

add conversion_options form

  • Conversion options forms added, just above the run conversion panel
  • Check if data is properly read and conversion options passed correctly to Converter.run_conversion()

conversion_options have a schema similar to source_data, with DataInterfaces keys as properties. So it should look like the first forms in the converter page of the gui.
An example of conversion_options data, composed of boolean options (other types are possible as well):

conversion_options = dict(
    EcephysInterface=dict(
        add_ecephys_raw=True,
        add_ecephys_processed=True,
        add_ecephys_spiking=True
    ),
    OphysInterface=dict(
        add_ophys_processed=True,
        add_ophys_raw=True,
        link_ophys_raw=False,
    )
)

Since this will be used exclusively for NWBConverter.run_conversion(), I think this should go below the metadata forms, where now we have the run conversion button and panel.
@bendichter what do you think?

@vinicvaz this should be straightforward to implement, pretty much the same way we're doing the other forms: the NWBConverter class has a method get_conversion_options_schema() that will return the schema. We should make sure to read data from it at the moment the user clicks run conversion

Dir / File explorer

Precisamos de um componente de navegacao para selecao de arquivos/pastas.

Componente React que parece interessante, monta a estrutura de pastas e arquivos a partir de um JSON file, que podemos pegar do backend:
https://github.com/uptick/react-keyed-file-browser#live-demo

Precisaríamos criar um Dash component encapsulando este (ou outro) React component:
https://dash.plotly.com/react-for-python-developers

Para nao ocupar muito espaco do UI (já que vários campos vao demandar esse tipo de navegacao), podemos colocar o componente Dash embutido em um Modal:
https://dash-bootstrap-components.opensource.faculty.ai/docs/components/modal/

outras ideias @vinicvaz ?

  • Flask app deve ter propriedade root_path_files que deve ser inicializado junto com o app. Isso vai nos permitir setar root_paths diferentes case o programa esteja rodando local ou em um servidor remoto
  • Criar funcao no backend que, comecando do root_path_files, le os arquivos/pastas locais e devolve como JSON a ser usado pelo componente file_explorer do frontend.
  • O componente file_explorer do frontend deve chamar a funcao do backend para atualizacao desses dados JSON quando o usuário navegar para dentro de uma subpasta
  • Opcao de selecao de Pasta

name generically

It looks like there isn't much here that is NWB-specific in the implementation of the converter form. Maybe that part can be refactored out into "json-schema-dash-form", and remove references to NWB. We can still use it for our purposes, but make it clear that this is a tool that can be used broadly for any user that wants to generate a Dash form from a json-schema

Dash Error: Can't open app

Hi,

I've tried using nwb-web-gui multiple ways (install via pip and latest github commit) but I can't seem to launch it. I've tried using python version 3.6-3.8 but I always get the same error:

NWB GUI running on localhost:5000
Data path: /Users/sportsnoah14/Documents/GitHub
/Users/sportsnoah14/opt/miniconda3/envs/nwb-web-gui/lib/python3.8/site-packages/nwb_web_gui/dashapps/pages/converter/init_coverter.py:2: UserWarning: 
The dash_html_components package is deprecated. Please replace
`import dash_html_components as html` with `from dash import html`
  import dash_html_components as html
/Users/sportsnoah14/opt/miniconda3/envs/nwb-web-gui/lib/python3.8/site-packages/nwb_web_gui/dashapps/pages/converter/converter.py:3: UserWarning: 
The dash_core_components package is deprecated. Please replace
`import dash_core_components as dcc` with `from dash import dcc`
  import dash_core_components as dcc
Traceback (most recent call last):
  File "/Users/sportsnoah14/opt/miniconda3/envs/nwb-web-gui/bin/nwbgui", line 8, in <module>
    sys.exit(cmd_line_shortcut())
  File "/Users/sportsnoah14/opt/miniconda3/envs/nwb-web-gui/lib/python3.8/site-packages/nwb_web_gui/cmd_line.py", line 107, in cmd_line_shortcut
    app = init_app()
  File "/Users/sportsnoah14/opt/miniconda3/envs/nwb-web-gui/lib/python3.8/site-packages/nwb_web_gui/__init__.py", line 40, in init_app
    from .dashapps.pages.converter.init_coverter import init_converter
  File "/Users/sportsnoah14/opt/miniconda3/envs/nwb-web-gui/lib/python3.8/site-packages/nwb_web_gui/dashapps/pages/converter/init_coverter.py", line 3, in <module>
    from nwb_web_gui.dashapps.pages.converter.converter import ConverterForms
  File "/Users/sportsnoah14/opt/miniconda3/envs/nwb-web-gui/lib/python3.8/site-packages/nwb_web_gui/dashapps/pages/converter/converter.py", line 10, in <module>
    from json_schema_to_dash_forms.forms import SchemaFormContainer
  File "/Users/sportsnoah14/opt/miniconda3/envs/nwb-web-gui/lib/python3.8/site-packages/json_schema_to_dash_forms/__init__.py", line 1, in <module>
    from .forms import SchemaFormContainer
  File "/Users/sportsnoah14/opt/miniconda3/envs/nwb-web-gui/lib/python3.8/site-packages/json_schema_to_dash_forms/forms.py", line 17, in <module>
    class SchemaFormItem(dbc.FormGroup):
  File "/Users/sportsnoah14/opt/miniconda3/envs/nwb-web-gui/lib/python3.8/site-packages/dash_bootstrap_components/__init__.py", line 51, in __getattr__
    raise AttributeError(
AttributeError: FormGroup was deprecated in dash-bootstrap-components version 1.0.0. You are using 1.0.1. For more details please see the migration guide: https://dash-bootstrap-components.opensource.faculty.ai/migration-guide/

Any idea what could be the problem? This is a fresh conda environment so there shouldn't be any package version conflicts.

Restructure app

Reorganize directories and files.
Clean up garbage/unused files.
Make nwb-web-gui an installable package.

Issue with custom converter

Hey!

I'm trying to use the nwb-web-gui with a custom converter. The converter is very simple and taken almost directly from the simple tutorial available in the nwb-conversion-tools github :

class exempleImageConverter(NWBConverter):
    data_interface_classes = dict(
        TiffImaging=TiffImagingInterface
    )

I got 2 errors. The first was reported on json-schema-to-dash-forms where it belongs, but I wasn't able to fix the second one. I believe the error comes from the schema conversion, althrough I am not sure. Here is the traceback :

Source data is valid!
172.16.11.240 - - [06/Aug/2021 14:43:54] "POST /converter/_dash-update-component HTTP/1.1" 500 -
Error on request:
Traceback (most recent call last):
  File "/home/willaem/.local/lib/python3.8/site-packages/werkzeug/serving.py", line 319, in run_wsgi
    execute(self.server.app)
  File "/home/willaem/.local/lib/python3.8/site-packages/werkzeug/serving.py", line 308, in execute
    application_iter = app(environ, start_response)
  File "/home/willaem/.local/lib/python3.8/site-packages/flask/app.py", line 2088, in __call__
    return self.wsgi_app(environ, start_response)
  File "/home/willaem/.local/lib/python3.8/site-packages/flask/app.py", line 2073, in wsgi_app
    response = self.handle_exception(e)
  File "/home/willaem/.local/lib/python3.8/site-packages/flask/app.py", line 2070, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/willaem/.local/lib/python3.8/site-packages/flask/app.py", line 1515, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/home/willaem/.local/lib/python3.8/site-packages/flask/app.py", line 1513, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/willaem/.local/lib/python3.8/site-packages/flask/app.py", line 1499, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
  File "/home/willaem/.local/lib/python3.8/site-packages/dash/dash.py", line 1096, in dispatch
    response.set_data(func(*args, outputs_list=outputs_list))
  File "/home/willaem/.local/lib/python3.8/site-packages/dash/dash.py", line 1017, in add_context
    output_value = func(*args, **kwargs)  # %% callback invoked %%
  File "/home/willaem/.local/lib/python3.8/site-packages/nwb_web_gui/dashapps/pages/converter/converter.py", line 361, in get_metadata
    self.metadata_forms.construct_children_forms()
  File "/home/willaem/.local/lib/python3.8/site-packages/json_schema_to_dash_forms/forms.py", line 666, in construct_children_forms
    iform = SchemaForm(
  File "/home/willaem/.local/lib/python3.8/site-packages/json_schema_to_dash_forms/forms.py", line 282, in __init__
    self.make_form(properties=schema['properties'])
  File "/home/willaem/.local/lib/python3.8/site-packages/json_schema_to_dash_forms/forms.py", line 299, in make_form
    item = SchemaForm(schema=v, key=k, parent_form=self)
  File "/home/willaem/.local/lib/python3.8/site-packages/json_schema_to_dash_forms/forms.py", line 282, in __init__
    self.make_form(properties=schema['properties'])
  File "/home/willaem/.local/lib/python3.8/site-packages/json_schema_to_dash_forms/forms.py", line 324, in make_form
    iform = SchemaForm(schema=schema, key=f'{k}-{index}', parent_form=self)
  File "/home/willaem/.local/lib/python3.8/site-packages/json_schema_to_dash_forms/forms.py", line 255, in __init__
    self.owner_class = schema.get('tag', '')
AttributeError: 'list' object has no attribute 'get'

Thanks in advance!

button to import and export metadata as yaml (or json)

Export: Create a yaml file with all entered fields. If the field is empty, do not create the key for that field

Import: Take an exported yaml file and populate the metadata form with it. Should be able to import metadata from multiple yaml files. (If a key is missing, do not overwrite the form field with an empty string)

CI and testing

Create basic tests for CI:

  • create CI routine with Actions
  • initialize app by command line shortcut
  • access /converter, check http response 200
  • access /viewer, check http response 200
  • access /shutdown, check if app closed

Show JSON

Deve mostrar os valores atualizados quando os campos sao preenchidos pelo usuário.
Nao deve ser editável

Alteracoes GUI

  • Campos devem ser criados a partir das keys do schema, nao apenas dos dados
  • Tipo de campos deve afetar o tipo de elemento no frontend (str, int, datetime, dropdown, subgrupo)
  • Campos devem ser preenchidos (nao apenas placeholders) com dados enviados
  • Cor das abas das Tabs devem ser da mesma cor dos headers ao lado esquerdo
  • Campos estao muito separados dos labels em cada item de formulario
  • Usar Checklist em vez de toggle para as opcoes boolean (https://dash-bootstrap-components.opensource.faculty.ai/docs/components/input/)

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.