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

Rewrite for client side using *cifplayer* and add external ML predictions #4

Open
wants to merge 37 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
2827ad3
$mol init
stan-donarise Jun 13, 2024
670d4c6
$mpds_tmdne_app initial
stan-donarise Jun 14, 2024
6b45f11
mpds -> optimade namespace
stan-donarise Jun 17, 2024
aa9d219
chore
stan-donarise Jun 17, 2024
b5e771f
swipeable card
stan-donarise Jun 28, 2024
d89ca6a
userSelect: 'none'
stan-donarise Jun 28, 2024
204035f
chore
stan-donarise Jun 29, 2024
8ab8d62
prefetch in background
stan-donarise Jun 29, 2024
b5a603c
Merge pull request #1 from stan-donarise/main
blokhin Jun 29, 2024
3730b09
Update index.html
stan-donarise Jun 29, 2024
b10257a
send user answer (post)
stan-donarise Jun 29, 2024
beea823
Update swipe.view.ts
stan-donarise Jun 29, 2024
ab2e0b8
$optimade_tmdne_swipe: simplify
stan-donarise Jun 29, 2024
d9dd8a8
$optimade_tmdne_app: update before post
stan-donarise Jun 29, 2024
2a53a8e
Polish styles and fix typo
blokhin Jun 29, 2024
0686d00
Merge branch 'main' of https://github.com/stan-donarise/this-material…
blokhin Jun 29, 2024
9ae2ca7
Fix prediction table on mobile screens
blokhin Jun 29, 2024
6481c9f
Merge pull request #2 from stan-donarise/main
blokhin Jun 29, 2024
060dc6a
Fix results saving
blokhin Jun 29, 2024
4bef46a
fix card hiding
stan-donarise Jun 29, 2024
9caefa5
Fix TS types and use cached Optimade structure
blokhin Jun 29, 2024
e74487f
Update compilation info
blokhin Jun 29, 2024
5089304
Merge remote-tracking branch 'upstream/main'
stan-donarise Jun 30, 2024
23a680c
$optimade_tmdne_html_view removed
stan-donarise Jun 30, 2024
26081c9
Fix links
blokhin Jul 5, 2024
ebaf73a
Merge remote-tracking branch 'upstream/main'
stan-donarise Jul 7, 2024
2eb1b6b
param_min_height prop added
stan-donarise Jul 7, 2024
a13dd10
Merge pull request #3 from stan-donarise/main
blokhin Jul 7, 2024
1422f62
Add footer and polish look&feel at the different screen resolutions
blokhin Jul 9, 2024
1a0187e
Fix a screenshot
blokhin Jul 9, 2024
ee4d3a8
fix swiped card movement (#5)
stan-donarise Jul 10, 2024
e88fa09
request body instead of query string
stan-donarise Jul 10, 2024
52c0568
Merge pull request #7 from stan-donarise/requset-body-1
blokhin Jul 10, 2024
a28a7df
fix excess fetch on start
stan-donarise Jul 29, 2024
b5f3550
fqn attrs
stan-donarise Jul 29, 2024
10f8618
Rename random_number -> random_sample
blokhin Jul 29, 2024
72c6375
Merge pull request #9 from stan-donarise/fix-excess-fetch
blokhin Jul 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* -text
23 changes: 23 additions & 0 deletions .github/workflows/deploy-to-gh-pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: build demo

on:
workflow_dispatch:
push:
pull_request:

jobs:
build:

runs-on: ubuntu-latest

steps:

- uses: hyoo-ru/mam_build@master2
with:
package: optimade/tmdne
modules: app

- uses: JamesIves/[email protected]
with:
branch: gh-pages
folder: optimade/tmdne/app/-
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-*
6 changes: 0 additions & 6 deletions Dockerfile

This file was deleted.

42 changes: 21 additions & 21 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
MIT License

Copyright (c) 2023 Matthew Evans

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
MIT License
Copyright (c) 2023 Matthew Evans
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
35 changes: 32 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,38 @@
<h1 align="center">💎 <a href="thismaterialdoesnotexist.com">this-material-does-not-exist</a> 💎</h1>
<h1 align="center">💎 <a href="https://thismaterialdoesnotexist.com">this-material-does-not-exist</a> 💎</h1>

Get given random crystal structures predicted by ML materials discovery projects, and vote on whether you think it should be synthesizable (or, at least, whether it is worth trying!)

Currently uses [crystaltoolkit](https://docs.crystaltoolkit.org) and data from the
Currently uses [cifplayer](https://github.com/tilde-lab/cifplayer) and data from the
[OPTIMADE API](https://optimade.org) for the recent [Google DeepMind
paper](https://github.com/google-deepmind/materials_discovery).
The physical properties prediction is done dynamically by [MPDS ML server](https://mpds.io/ml).

![2023-12-10-001838_1095x878_scrot](https://github.com/ml-evs/this-material-does-not-exist/assets/7916000/678ba7ec-d929-438e-8637-3dad5bf26493)
![GNome_d582d1239f_screenshot](https://raw.githubusercontent.com/mpds-io/this-material-does-not-exist/main/d582d1239f.png)


## Build

The `cifplayer` is powered by `$mol` framework. Note that, unlike many other frontend frameworks, `$mol` provides the same single environment for all its projects, under the standard namespace scheme. That is, all your `$mol`-based code lives inside the same directory `$MOL_HOME`. So if you don't have `$MOL_HOME` yet, please create it and navigate there

```bash
mkdir $MOL_HOME && cd $MOL_HOME
```

Then build with

```bash
npm exec mam optimade/tmdne/app
```

This will fetch the MAM server (MAM stands for the `$mol` abstract modules), clone this project, and compile it inside `optimade/tmdne/app/-/` subfolder. You will need the `web.js` bundle, that's it.


## Develop

Similarly to above, inside the `$MOL_HOME`, start the MAM dev-server with

```bash
npm exec mam
```

and navigate to http://localhost:9080, there select `optimade` namespace, then `tmdne`, then `app`. As you go through the folder structure, the selected project is being cloned and compiled on the fly, inside the corresponding subfolder of `$MOL_HOME`.
8 changes: 8 additions & 0 deletions app/app.view.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@media all and (max-width: 850px) {
[optimade_tmdne_app_param_mae], [optimade_tmdne_app_param_name] { display: none; }
[optimade_tmdne_app_acks] { display: none; }
}

@media all and (max-height: 650px) {
[optimade_tmdne_app_prediction] { display: none; }
}
151 changes: 151 additions & 0 deletions app/app.view.css.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
namespace $.$$ {

$mol_style_define( $optimade_tmdne_app, {

overflow: 'hidden',
flex: {
direction: 'column',
},
align: {
items: 'center',
},

Player: {
flex: {
grow: 1,
},
width: '100%',
opacity: 1,
transition: 'opacity 0.15s',
'[optimade_tmdne_app_player_hidden]': {
'true': {
opacity: 0.1,
},
},
},

Head_space: {
position: 'absolute',
top: $mol_gap.block,
left: 0,
right: 0,
flex: {
grow: 1,
},
pointerEvents: 'none',
},

Head_card: {
pointerEvents: 'auto',
margin: 'auto',
width: '35%',
textAlign: 'center',
},

Head_title: {
userSelect: 'none',
justify: {
content: 'center',
},
font: {
size: '1.2rem',
},
},

Prediction: {
userSelect: 'none',
font: {
size: '0.7rem',
},
lineHeight: '16px',
flex: {
grow: 0,
wrap: 'wrap',
},
position: 'absolute',
left: $mol_gap.block,
bottom: '11rem',
pointerEvents: 'none',
opacity: 1,
transition: 'opacity 0.15s',
'[optimade_tmdne_app_prediction_hidden]': {
'true': {
opacity: 0,
},
},
},

Param: {
gap: '0.3rem',
flex: {
wrap: 'wrap',
},
},

Param_name: {
font: {
weight: 700,
},
},

Param_symbol: {
flex: {
direction: 'row',
},
},

Param_unit: {
flex: {
direction: 'row',
},
},

Param_mae_unit: {
flex: {
direction: 'row',
},
},

Param_value: {
gap: '0.25rem',
},

Foot: {
justify: {
content: 'space-between',
},
width: '24rem',
position: 'absolute',
bottom: '5.3rem',

pointerEvents: 'none',
transition: 'opacity 0.2s',
opacity: 1,
'[optimade_tmdne_app_foot_hidden]': {
'true': {
opacity: 0,
},
},
zIndex: 1,
},

Hint_no: {
pointerEvents: 'auto',
color: '#ff6666',
},

Hint_yes: {
pointerEvents: 'auto',
color: $mol_theme.current,
},

Acks: {
font: {
size: '0.7rem',
},
zIndex: 0,
},

} )

}
92 changes: 92 additions & 0 deletions app/app.view.tree
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
$optimade_tmdne_app $mol_view
title \This Material Does Not Exist?
number? 1
plugins /
<= Theme $mol_theme_auto
rotating? false
number_swiped? 0
number_prefetch? 0
sub /
<= Player $optimade_cifplayer_player
fullscreen? => player_fullscreen?
attr *
fullscreen <= player_fullscreen?
optimade_tmdne_app_player_hidden <= card_holding
data <= json null
Fullscreen null
Overlays null
event *
pointerdown? <=> player_pointerdown? null
pointerup? <=> player_pointerup? null
<= Head_space $mol_view
sub /
<= Head_card $mol_list
sub /
<= Head_title $mol_paragraph
title \Does this material exist?
<= Prediction $mol_list
attr *
optimade_tmdne_app_prediction_hidden <= rotating
sub <= params /
<= Param* $mol_view
sub /
<= Param_name* $mol_paragraph
title <= param_name* \
<= Param_symbol* $mol_html_view
minimal_height <= param_min_height 22
html <= param_symbol* \
\=
<= Param_value* $mol_view
sub /
<= param_value* \
<= Param_unit* $mol_html_view
minimal_height <= param_min_height
html <= param_unit* \
<= Param_mae* $mol_view
sub /
\(±
<= param_mae* \
<= Param_mae_unit* $mol_html_view
minimal_height <= param_min_height
html <= param_unit* \
\)
<= Foot $mol_view
attr *
optimade_tmdne_app_foot_hidden <= rotating
sub /
<= Hint_no $mol_button_minor
title \ᐊ No
click? <=> click_no? null
<= Hint_yes $mol_button_minor
title \Yes ᐅ
click? <=> click_yes? null
^ cards / <= Card* $optimade_tmdne_card
name <= card_name* \
loaded <= card_loaded* false
why? <=> why*? \
pointer_holding? <=> card_holding? false
swiped_to? <=> swiped_to*? \
swipe_to_right => swipe_to_right*
swipe_to_left => swipe_to_left*
<= Acks $mol_view
sub /
<= Acks_a $mol_link
uri \https://www.optimade.org
sub /
\Powered by Optimade
<= Acks_b $mol_link
uri \https://github.com/tilde-lab/cifplayer
sub /
\and cifplayer
<= Acks_c $mol_link
uri \https://github.com/google-deepmind/materials_discovery
sub /
\using the GNome dataset
<= Acks_d $mol_link
uri \https://github.com/ml-evs/this-material-does-not-exist
sub /
\developed on GitHub
<= Acks_e $mol_link
uri \https://thispersondoesnotexist.com
sub /
\and inspired by...
Loading