|
1 |
| -# Mash |
| 1 | +# Crystal Toolkit |
2 | 2 |
|
3 |
| -**The current state of this repo is for testing and debugging, not for end users!* |
| 3 | +*Crystal Toolkit is still a very new project. While it has had its first release, |
| 4 | +bugs and major changes are still to be expected. Please report any issues you may |
| 5 | +encounter.* |
4 | 6 |
|
5 |
| -## Installation |
| 7 | +## Table of Contents |
6 | 8 |
|
7 |
| -## Usage |
| 9 | +## Installation and use |
8 | 10 |
|
9 |
| -### StructureComponent |
| 11 | +To use Crystal Toolkit, simply visit [https://viewer.materialsproject.org](https://viewer.materialsproject.org) (address subject to change). |
10 | 12 |
|
11 |
| -### SpectrumComponent |
12 | 13 |
|
13 |
| -### PhaseDiagramComponent |
| 14 | +If you would like to test Crystal Toolkit on your own computer, download and run our [Docker image from DockerHub](...): |
14 | 15 |
|
15 |
| -### PeriodicTableComponent |
| 16 | +```python |
| 17 | +docker .. |
| 18 | +docker ... -env pmg_mapi_key=YOUR_API_KEY_HERE |
| 19 | +``` |
| 20 | + |
| 21 | +If you would like to use Crystal Toolkit for its library of UI components |
| 22 | +for your own Dash app, you can pip install it: |
| 23 | + |
| 24 | +```python |
| 25 | +pip install crystal-toolkit |
| 26 | +``` |
| 27 | + |
| 28 | +### Easy viewing of crystal structures and molecules from Python |
| 29 | + |
| 30 | +Installing Crystal Toolkit via pip also gives you the useful command `view`: |
| 31 | + |
| 32 | +```python |
| 33 | +from crystal_toolkit import view_online |
| 34 | +view_online(my_struct) # returns https://viewer.materialsproject.org/?token=... |
| 35 | +``` |
| 36 | + |
| 37 | +This will generate a link to view your crystal structure or molecule online. |
| 38 | + |
| 39 | +In future, support for online, interactive viewing of other classes are planned, |
| 40 | +in addition to inline viewing in a Jupyter notebook. |
| 41 | + |
| 42 | +## Contributing |
| 43 | + |
| 44 | +Contributions are welcome! [We have an open and inclusive contribution policy](...). |
| 45 | + |
| 46 | +Please use the [Issues]() page to report bugs and feature requests, pull requests are also welcome. |
| 47 | +This is the first significant web app we've developed using Dash and we're still figuring out |
| 48 | +best practices, so comments on architectural choices are also welcome. |
| 49 | + |
| 50 | +Technical guidelines on contributions are as follows: |
| 51 | + |
| 52 | +### Contribute an MPComponent |
| 53 | + |
| 54 | +An `MPComponent` is designed to render an instance of an "MSONable" |
| 55 | +object from a Materials Project software code. |
| 56 | + |
| 57 | +Currently there are MPComponents for the following classes: |
| 58 | + |
| 59 | +- `pymatgen.core.Structure` |
| 60 | +- `pymatgen.core.Molecule` |
| 61 | +- `pymatgen.analysis.graphs.StructureGraph` |
| 62 | +- `pymatgen.analysis.graphs.MoleculeGraph` |
| 63 | + |
| 64 | +See the current [Issues](???) page for any components that still need implementing. |
| 65 | + |
| 66 | +Before using any MPComponents in your app, you must register your app object and cache |
| 67 | +(if applicable) with Crystal Toolkit. |
| 68 | + |
| 69 | +```python |
| 70 | +import crystal_toolkit as ct |
| 71 | +ct.register_app() # Optional, but required for interactivity |
| 72 | +ct.register_cache() # Optional, but often useful for performance |
| 73 | +``` |
| 74 | + |
| 75 | +To use an MPComponent, the standard initializer takes an `id` like any other Dash component and `contents` |
| 76 | +which can be an instance of the corresponding MSONable class or `None`. |
| 77 | + |
| 78 | +For example, |
| 79 | + |
| 80 | +```python |
| 81 | +import crystal_toolkit as ct |
| 82 | +struct_component = ct.StructureMoleculeComponent(my_struct, id="my_structure_visualizer") |
| 83 | +``` |
| 84 | + |
| 85 | +Then, you can add its default layout to your `app` using `struct_component.default_layout` |
| 86 | +or, if you want more customizability, you can `print(struct_component)` and see |
| 87 | +what other layouts it supports (for example, it might have an optional set of controls associated |
| 88 | +with it). |
| 89 | + |
| 90 | +#### Implementing an MPComponent |
| 91 | + |
| 92 | +... |
| 93 | + |
| 94 | +### Contribute a Crystal Toolkit Panel |
| 95 | + |
| 96 | +A `PanelComponent` is a sub-class |
| 97 | + |
| 98 | +#### Implementing a PanelComponent |
| 99 | + |
| 100 | +### Contribute a React component |
| 101 | + |
| 102 | +Some `MPComponents` require functionality not offered by core Dash components, |
| 103 | +for example the crystal viewer itself which requires 3D rendering capabilities. |
| 104 | + |
| 105 | +If you need an additional React component, you will first need to set up |
| 106 | +your development environment using `npm install ...` |
| 107 | + |
| 108 | +...simply create `YourComponent.react.js` |
| 109 | +in `~/src/components/`, import it in `~/src/index.js`, and run: |
| 110 | + |
| 111 | +`builder...` |
| 112 | + |
| 113 | +If you have any new dependencies, add them using `npm install -S ...`. |
| 114 | + |
| 115 | +### Tests |
| 116 | + |
| 117 | +Tests are ideal, however tests are not required to start contributing |
| 118 | +to Crystal Toolkit. Since Crystal Toolkit itself does not itself contain any new |
| 119 | +scientific analysis capabilities, but instead builds upon other libraries |
| 120 | +like [pymatgen](http://pymatgen.org), comprehensive testing isn't as |
| 121 | +mission critical. *However, tests are still encouraged wherever possible* |
| 122 | +and the long-term health of this project will rely on good testing. |
| 123 | + |
| 124 | +New React components should have an example added to usage.py and edit `tests/?` |
| 125 | + |
| 126 | +New subclasses of `MPComponent` and `PanelComponent` can have tests |
| 127 | +written purely in Python, a good test for a `PanelComponent` would be to |
| 128 | +test the output of `update_contents()`. |
| 129 | + |
| 130 | +## Acknowledgements |
| 131 | + |
| 132 | +Thank you to all the authors and maintainers of the libraries Crystal Toolkit |
| 133 | +depends upon, and in particular [pymatgen](http://pymatgen.org) for crystallographic |
| 134 | +analysis and [Dash from Plotly](https://plot.ly/products/dash/) for their web app framework. Thank you |
| 135 | +to the [NERSC Spin](http://www.nersc.gov/users/data-analytics/spin/) service for hosting the app and |
| 136 | +for technical support. |
| 137 | + |
| 138 | +## Contact |
| 139 | + |
| 140 | +Please contact @mkhorton with any queries. |
0 commit comments