-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathNOTES
182 lines (131 loc) · 6.12 KB
/
NOTES
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
Overall:
Thinking about it the real justification for this project
is to do deep learning on the GrainBoundaries, Dynamics,
and Energetics, and to have a database of all these calculations.
Strictly speaking each view of a grain boundary should have a neural net
attached to it which is capable producing its dynamics, it's potential energy
surface etc.
Visualization Stuff:
Thinking more now about how the library is going to look:
I'd really like some kind of X11 server embedding in the page
That would make it very simple for a user to look at the grain
boundary say using AtomEye and flicker around with things there.
There are some packages which seem to be moving towards a Javascript
style X server... I feel like a decent solution would be just to stream
the output of a server side x11 stuff to the browser.
VNC (virtual network computing) and x11vnc.
ffmpeg can also grab x11 and turn it into video for streaming.
X11 is a display server Presents a common API for drawing, keyboard, mouse, other events
There is a remote protocol so you can tunnel via tcp, ssh etc.
https://prezi.com/jrfg5ziqtwhn/x11-in-a-modern-web-browser-why/
https://github.com/GothAck/javascript-x-server.git
http://stackoverflow.com/questions/19556947/html5-javascript-x11-server
https://docs.oracle.com/cd/E26502_01/html/E28056/gmceg.html
Although looking into the code I realize chemview.js will
actually provide the client side visualization that I
actually need, and can communicate in a much nice format back
and forth with json.
Films:
If we want to see a movie imovie might be a useful way of wrapping up a variety
of different grain boundaries into a brady brunch/1970s style split screen of
fun.
Server Development:
Browsing file systems, uploading files etc:
Advanced views and custom decorators:
h4ttp://exploreflask.readthedocs.io/en/latest/configuration.html
http://exploreflask.readthedocs.io/en/latest/views.html
Standard Patterns for uploading files:
http://flask.pocoo.org/docs/0.10/patterns/fileuploads/
Flask-Uploads allows application to handle file uploading, and
serving the uploaded files.
Some more templates for application structure:
https://github.com/imwilsonxu/fbone
https://github.com/sloria/cookiecutter-flask
Module for metric space indexing.
http://well-adjusted.de/~jrspieker/mspace/
For injecting Jinja Templates with extra spice!
Note: This is Flask specific!
I know this post is quite old, but there are better methods of doing
this in the newer versions of Flask using context processors.
Variables can easily be created:
@app.context_processor
def example():
return dict(myexample='This is an example')
The above can be used in a Jinja2 template with Flask like so:
{{ myexample }}
Which outputs This is an example
As well as full fledged functions:
@app.context_processor
def utility_processor():
def format_price(amount, currency=u'€'):
return u'{0:.2f}{1}'.format(amount, currency)
return dict(format_price=format_price)
The above when used like so:
{{ format_price(0.33) }}
(Which outputs the input price with the currency symbol)
Also a note on how to create a recursive list patttern
http://stackoverflow.com/questions/11922893/jinja2-and-json
Tue 10 May 2016 15:18:18 BST
Spent first part of day messing around with views and
d3 js stuff. Can read d3.js documentation here:
https://d3js.org/#introduction
Key lessons were...
1) Inspect everything you do in javascript in the console
makes debugging things alot simpler.
2) Passing the dict_struct via jinja requires some
juggling of python to javascript::
var data = jQuery.parse(json.dumps([{data},{data},...{data}]))
and in the jinja template we dont want the json string to be escaped
so we need to mark the data as safe {{data|safe}}.
Might also be able to exploit this kind of pattern
{{item|tojson|safe}}. Funny how reading the documentation becomes
alot easier after you've had to solve all the problems.
The standard configuration for Jinja in Flask is layed out here:
http://flask.pocoo.org/docs/0.10/templating/#standard-filters
as follows. autoescaping is enabled for all templates ending in .html
.htm, .xml, as well as .xhtml
3) opt in/out of autoescaping via {% autoescape %} tag.}
some global variables available withing Jinja2 templates
config
request
session
g
url_for
get_flashed_messages()
3) Adding custom filters to flask:
@app.template_filter('reverse')
def reverse_filter(s):
return s[::-1]
def reverse_filter(s):
return s[::-1]
app.jinja_env.filters['reverse'] = reverse_filter
A cool way of including markdown into a jinja script is
described here:
https://gist.github.com/glombard/7554134
# One thing we should definitely look at si the PHONONPY
# EIGENMODES For a Grain Boundary!
https://atztogo.github.io/phonopy/setting-tags.html#irreducible-representation-related-tags
Docker IMAGE:
To see the current running docker instance:
docker ps
To list available images:
docker images
To enter the docker container (an image instance) can use container id or NAME:
docker exec -it c631c5dccd91 bash
to open ssh port to the machine
ssh -L 5000:localhost:8888 imeall
To check error logs (useful for debugging web framework).
docker logs CONTAINER
To set up an ssh port:
ssh -L 5000:localhost:8888 imeall
To set the image running:
docker run -d -p 5000:5000 -v /home/lambert/pymodules/imeall/imeall/grain_boundaries:/opt/imeall/grain_boundaries:ro manuscript-imeall
docker exec -it sleepy_dubinsky bash
#The docker logs print to stderr.
docker logs c631c5dccd91 >stdout.log 2>stderr.log
Fixing the old favicon issue.
https://stackoverflow.com/questions/5307417/how-to-skip-the-commit-message-step-in-git-commit-amend
The second level of testing is the "accuracy" of the structures and the properties calculated which
can only be compared for consistency between different interatomic potentials, and for accuracy
with reference to experimental data. It is these sorts of comparisons, between potentials and between
experimental data, that the Imeall tool is meant to enable.