Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

conflict with jupyterlab-variableInspector #7863

Closed
zhehao opened this issue Nov 19, 2018 · 3 comments
Closed

conflict with jupyterlab-variableInspector #7863

zhehao opened this issue Nov 19, 2018 · 3 comments
Assignees

Comments

@zhehao
Copy link

zhehao commented Nov 19, 2018

I found that beakerx-jupyterlab is conflicted with jupyterlab-variableInspector, variableInspector widget becomes static(no reaction to variable redefinition or new variables) when I import beakerx into the kernel, here is my jupyterlab environment:

JupyterLab v0.35.4
Known labextensions:
   app dir: ~\AppData\Local\Continuum\anaconda3\share\jupyter\lab
        @jupyter-widgets/jupyterlab-manager v0.38.1 enabled  ok
        @jupyterlab/celltags v0.1.4 enabled  ok
        @jupyterlab/toc v0.6.0 enabled  ok
        @pyviz/jupyterlab_pyviz v0.6.3 enabled  ok
        beakerx-jupyterlab v1.2.0 enabled  ok
        jupyterlab-drawio v0.5.0 enabled  ok
        jupyterlab_variableinspector v0.1.0 enabled  ok*

Is the conflict resolvable? As variableInspector is quite useful for data science, I think many people would like to use it with beakerx.

@piorek
Copy link
Contributor

piorek commented Jan 9, 2019

@LeeTZ
I debugged this and it looks the problem lays in https://github.com/lckr/jupyterlab-variableInspector/blob/8f975ae5cd4624660a1400a7121a148d063cf9b9/src/inspectorscripts.ts#L116

After doing from beaker import * certain objects (more than one) are throwing an exception when doing obj = eval(v) and that leads to vardic being [] hence the error.

Im not an python expert but changing that function to

def _jupyterlab_variableinspector_dict_list():
    def keep_cond(v):
        try:
            obj = eval(v)
            if isinstance(obj, str):
                return True
            if tf and isinstance(obj, tf.Variable):
                return True
            if pd and pd is not None and (
                isinstance(obj, pd.core.frame.DataFrame)
                or isinstance(obj, pd.core.series.Series)):
                return True
            if str(obj)[0] == "<":
                return False
            if  v in ['np', 'pd', 'pyspark', 'tf']:
                return obj is not None
            if str(obj).startswith("_Feature"):
                # removes tf/keras objects
                return False
            return True
        except:
            return False
    values = _jupyterlab_variableinspector_nms.who_ls()
    vardic = [{'varName': _v,
    'varType': type(eval(_v)).__name__,
    'varSize': str(_jupyterlab_variableinspector_getsizeof(eval(_v))),
    'varShape': str(_jupyterlab_variableinspector_getshapeof(eval(_v))) if _jupyterlab_variableinspe$
    'varContent': str(_jupyterlab_variableinspector_getcontentof(eval(_v))),
    'isMatrix': _jupyterlab_variableinspector_is_matrix(eval(_v))}
            for _v in values if keep_cond(_v)]
    return json.dumps(vardic, ensure_ascii=False)

fixed issue for me.

Should I make issue and/or PR in extension repo?

@piorek
Copy link
Contributor

piorek commented Jan 9, 2019

@LeeTZ I will create an issue and PR tomorrow

@piorek
Copy link
Contributor

piorek commented Jan 10, 2019

@zhehao my fix in jupyterlab-variableInspector was merged into master so it should be OK now

@LeeTZ LeeTZ closed this as completed Jan 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants