oasis-open / cti-stix-visualization

OASIS TC Open Repository: Lightweight visualization for STIX 2.0 objects and relationships
http://oasis-open.github.io/cti-stix-visualization
BSD 3-Clause "New" or "Revised" License
138 stars 43 forks source link

Add Jupyter extension, installable via python package #23

Closed chisholm closed 7 years ago

chisholm commented 7 years ago

Intended to fix issue #15.

I had to create a setup.py and invent some packages and names, in order to do this. So I don't know if you agree with my naming.

To install the extension, after having installed stix-visualization:

jupyter nbextension install --py stix2jupyter.viz
jupyter nbextension enable --py stix2jupyter.viz

To uninstall:

jupyter nbextension uninstall --py stix2jupyter.viz

(wish they both could be one command.) An example notebook command to make use of the extension:

from stix2jupyter.viz import display
display("""
[STIX JSON content here]
""")

The extension (actually the js code itself) still doesn't really work as we need it to, due to its problematic reliance on globals. So this is perhaps a step in the right direction as far as releaseability, but it isn't good enough yet.

This repo also contains a regular web application, which I had to modify to keep it working, after having changed the stix2viz code to be an AMD module. The web application must now also be structured as an AMD module, so I've fixed it so it still works, as far as I can test it. To see it while I still have the proper branch in place (which won't be long term), go to: https://chisholm.github.io/cti-stix-visualization/

The "fetch STIX from a URL" function still isn't easily testable due to cross-origin restrictions. There is content at github.com, but that's not the same domain as chisholm.github.io. So I haven't tested it.

chisholm commented 7 years ago

Actually, there's a test.json file in this repo, accessible from the same domain, which can be used to test the "fetch STIX from URL" function. That worked for me.

chisholm commented 7 years ago

Hmm... issue #16 purports to be required to fix #15. I hadn't interpreted this issue to be to fix the global variable problem. I thought it was simply to create the installable Jupyter notebook extension and nothing else. What all is entailed here?

gtback commented 7 years ago

I think fixing the global variable problem is necessary to include multiple graphs in the same Jupyter notebook (if I understand the issue behind #16 correctly).

chisholm commented 7 years ago

Yeah, but what the extension does (or doesn't do) is a different issue than making things installable as a notebook extension via a python package in the first place. I'd thought this was just about a repackaging or restructuring.

gtback commented 7 years ago

Looks good!

My preferences on naming:

We won't release a version of the Python package until we fix #16, but I think this is good to merge in now. If the renaming will take a long time, let's merge now and handle it separately, otherwise let's rename first.

chisholm commented 7 years ago

Renaming is done. To your points:

gtback commented 7 years ago

I was thinking about a co-existing npm package, but that's little more than an idea at this point. Maybe with the D3 customizations it's not that feasible.