Skip to content

Commit

Permalink
deploy: 8af3efe
Browse files Browse the repository at this point in the history
  • Loading branch information
RandomDefaultUser committed Apr 18, 2024
1 parent 31eaf0f commit 5134fd2
Show file tree
Hide file tree
Showing 55 changed files with 6,839 additions and 4,078 deletions.
11 changes: 11 additions & 0 deletions CONTRIBUTE.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
</li>
<li class="toctree-l2"><a class="reference internal" href="#branching-strategy">Branching strategy</a></li>
<li class="toctree-l2"><a class="reference internal" href="#developing-code">Developing code</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#formatting-code">Formatting code</a></li>
<li class="toctree-l3"><a class="reference internal" href="#adding-dependencies">Adding dependencies</a></li>
</ul>
</li>
Expand Down Expand Up @@ -183,6 +184,16 @@ <h2>Developing code<a class="headerlink" href="#developing-code" title="Permalin
<li><p>If you’re adding code that should be tested, add tests</p></li>
<li><p>If you’re adding or modifying examples, make sure to add them to <code class="docutils literal notranslate"><span class="pre">test_examples.py</span></code></p></li>
</ul>
<div class="section" id="formatting-code">
<h3>Formatting code<a class="headerlink" href="#formatting-code" title="Permalink to this headline"></a></h3>
<ul class="simple">
<li><p>MALA uses <a class="reference external" href="https://github.com/psf/black"><code class="docutils literal notranslate"><span class="pre">black</span></code></a> for code formatting</p></li>
<li><p>The <code class="docutils literal notranslate"><span class="pre">black</span></code> configuration is located in <code class="docutils literal notranslate"><span class="pre">pyproject.toml</span></code></p></li>
<li><p>Currently, no automatic code reformatting will be done in the CI, thus
please ensure that your code is properly formatted before creating a pull
request</p></li>
</ul>
</div>
<div class="section" id="adding-dependencies">
<h3>Adding dependencies<a class="headerlink" href="#adding-dependencies" title="Permalink to this headline"></a></h3>
<p>If you add additional dependencies, make sure to add them to <code class="docutils literal notranslate"><span class="pre">requirements.txt</span></code>
Expand Down
75 changes: 49 additions & 26 deletions _modules/mala/common/check_modules.html
Original file line number Diff line number Diff line change
Expand Up @@ -75,47 +75,70 @@

<h1>Source code for mala.common.check_modules</h1><div class="highlight"><pre>
<span></span><span class="sd">&quot;&quot;&quot;Function to check module availability in MALA.&quot;&quot;&quot;</span>

<span class="kn">import</span> <span class="nn">importlib</span>


<div class="viewcode-block" id="check_modules"><a class="viewcode-back" href="../../../api/mala.common.check_modules.html#mala.common.check_modules.check_modules">[docs]</a><span class="k">def</span> <span class="nf">check_modules</span><span class="p">():</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Check whether/which optional modules MALA can access.&quot;&quot;&quot;</span>
<span class="c1"># The optional libs in MALA.</span>
<span class="n">optional_libs</span> <span class="o">=</span> <span class="p">{</span>
<span class="s2">&quot;mpi4py&quot;</span><span class="p">:</span> <span class="p">{</span><span class="s2">&quot;available&quot;</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">&quot;description&quot;</span><span class="p">:</span>
<span class="s2">&quot;Enables inference parallelization.&quot;</span><span class="p">},</span>
<span class="s2">&quot;horovod&quot;</span><span class="p">:</span> <span class="p">{</span><span class="s2">&quot;available&quot;</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">&quot;description&quot;</span><span class="p">:</span>
<span class="s2">&quot;Enables training parallelization.&quot;</span><span class="p">},</span>
<span class="s2">&quot;lammps&quot;</span><span class="p">:</span> <span class="p">{</span><span class="s2">&quot;available&quot;</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">&quot;description&quot;</span><span class="p">:</span>
<span class="s2">&quot;Enables descriptor calculation for data preprocessing &quot;</span>
<span class="s2">&quot;and inference.&quot;</span><span class="p">},</span>
<span class="s2">&quot;oapackage&quot;</span><span class="p">:</span> <span class="p">{</span><span class="s2">&quot;available&quot;</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">&quot;description&quot;</span><span class="p">:</span>
<span class="s2">&quot;Enables usage of OAT method for hyperparameter &quot;</span>
<span class="s2">&quot;optimization.&quot;</span><span class="p">},</span>
<span class="s2">&quot;total_energy&quot;</span><span class="p">:</span> <span class="p">{</span><span class="s2">&quot;available&quot;</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">&quot;description&quot;</span><span class="p">:</span>
<span class="s2">&quot;Enables calculation of total energy.&quot;</span><span class="p">},</span>
<span class="s2">&quot;asap3&quot;</span><span class="p">:</span> <span class="p">{</span><span class="s2">&quot;available&quot;</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">&quot;description&quot;</span><span class="p">:</span>
<span class="s2">&quot;Enables trajectory analysis.&quot;</span><span class="p">},</span>
<span class="s2">&quot;dftpy&quot;</span><span class="p">:</span> <span class="p">{</span><span class="s2">&quot;available&quot;</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">&quot;description&quot;</span><span class="p">:</span>
<span class="s2">&quot;Enables OF-DFT-MD initialization.&quot;</span><span class="p">},</span>
<span class="s2">&quot;minterpy&quot;</span><span class="p">:</span> <span class="p">{</span><span class="s2">&quot;available&quot;</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> <span class="s2">&quot;description&quot;</span><span class="p">:</span>
<span class="s2">&quot;Enables minterpy descriptor calculation for data preprocessing.&quot;</span><span class="p">}</span>
<span class="s2">&quot;mpi4py&quot;</span><span class="p">:</span> <span class="p">{</span>
<span class="s2">&quot;available&quot;</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span>
<span class="s2">&quot;description&quot;</span><span class="p">:</span> <span class="s2">&quot;Enables inference parallelization.&quot;</span><span class="p">,</span>
<span class="p">},</span>
<span class="s2">&quot;horovod&quot;</span><span class="p">:</span> <span class="p">{</span>
<span class="s2">&quot;available&quot;</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span>
<span class="s2">&quot;description&quot;</span><span class="p">:</span> <span class="s2">&quot;Enables training parallelization.&quot;</span><span class="p">,</span>
<span class="p">},</span>
<span class="s2">&quot;lammps&quot;</span><span class="p">:</span> <span class="p">{</span>
<span class="s2">&quot;available&quot;</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span>
<span class="s2">&quot;description&quot;</span><span class="p">:</span> <span class="s2">&quot;Enables descriptor calculation for data preprocessing &quot;</span>
<span class="s2">&quot;and inference.&quot;</span><span class="p">,</span>
<span class="p">},</span>
<span class="s2">&quot;oapackage&quot;</span><span class="p">:</span> <span class="p">{</span>
<span class="s2">&quot;available&quot;</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span>
<span class="s2">&quot;description&quot;</span><span class="p">:</span> <span class="s2">&quot;Enables usage of OAT method for hyperparameter &quot;</span>
<span class="s2">&quot;optimization.&quot;</span><span class="p">,</span>
<span class="p">},</span>
<span class="s2">&quot;total_energy&quot;</span><span class="p">:</span> <span class="p">{</span>
<span class="s2">&quot;available&quot;</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span>
<span class="s2">&quot;description&quot;</span><span class="p">:</span> <span class="s2">&quot;Enables calculation of total energy.&quot;</span><span class="p">,</span>
<span class="p">},</span>
<span class="s2">&quot;asap3&quot;</span><span class="p">:</span> <span class="p">{</span>
<span class="s2">&quot;available&quot;</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span>
<span class="s2">&quot;description&quot;</span><span class="p">:</span> <span class="s2">&quot;Enables trajectory analysis.&quot;</span><span class="p">,</span>
<span class="p">},</span>
<span class="s2">&quot;dftpy&quot;</span><span class="p">:</span> <span class="p">{</span>
<span class="s2">&quot;available&quot;</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span>
<span class="s2">&quot;description&quot;</span><span class="p">:</span> <span class="s2">&quot;Enables OF-DFT-MD initialization.&quot;</span><span class="p">,</span>
<span class="p">},</span>
<span class="s2">&quot;minterpy&quot;</span><span class="p">:</span> <span class="p">{</span>
<span class="s2">&quot;available&quot;</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span>
<span class="s2">&quot;description&quot;</span><span class="p">:</span> <span class="s2">&quot;Enables minterpy descriptor calculation for data preprocessing.&quot;</span><span class="p">,</span>
<span class="p">},</span>
<span class="p">}</span>

<span class="c1"># Find out if libs are available.</span>
<span class="k">for</span> <span class="n">lib</span> <span class="ow">in</span> <span class="n">optional_libs</span><span class="p">:</span>
<span class="n">optional_libs</span><span class="p">[</span><span class="n">lib</span><span class="p">][</span><span class="s2">&quot;available&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">importlib</span><span class="o">.</span><span class="n">util</span><span class="o">.</span><span class="n">find_spec</span><span class="p">(</span><span class="n">lib</span><span class="p">)</span> \
<span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span>
<span class="n">optional_libs</span><span class="p">[</span><span class="n">lib</span><span class="p">][</span><span class="s2">&quot;available&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="p">(</span>
<span class="n">importlib</span><span class="o">.</span><span class="n">util</span><span class="o">.</span><span class="n">find_spec</span><span class="p">(</span><span class="n">lib</span><span class="p">)</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span>
<span class="p">)</span>

<span class="c1"># Print info about libs.</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;The following optional modules are available in MALA:&quot;</span><span class="p">)</span>
<span class="k">for</span> <span class="n">lib</span> <span class="ow">in</span> <span class="n">optional_libs</span><span class="p">:</span>
<span class="n">available_string</span> <span class="o">=</span> <span class="s2">&quot;installed&quot;</span> <span class="k">if</span> <span class="n">optional_libs</span><span class="p">[</span><span class="n">lib</span><span class="p">][</span><span class="s2">&quot;available&quot;</span><span class="p">]</span> \
<span class="k">else</span> <span class="s2">&quot;not installed&quot;</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;</span><span class="si">{0}</span><span class="s2">: </span><span class="se">\t</span><span class="s2"> </span><span class="si">{1}</span><span class="s2"> </span><span class="se">\t</span><span class="s2"> </span><span class="si">{2}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">lib</span><span class="p">,</span> <span class="n">available_string</span><span class="p">,</span>
<span class="n">optional_libs</span><span class="p">[</span><span class="n">lib</span><span class="p">][</span><span class="s2">&quot;description&quot;</span><span class="p">]))</span>
<span class="n">optional_libs</span><span class="p">[</span><span class="n">lib</span><span class="p">][</span><span class="s2">&quot;available&quot;</span><span class="p">]</span> <span class="o">=</span> \
<span class="n">importlib</span><span class="o">.</span><span class="n">util</span><span class="o">.</span><span class="n">find_spec</span><span class="p">(</span><span class="n">lib</span><span class="p">)</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span></div>
<span class="n">available_string</span> <span class="o">=</span> <span class="p">(</span>
<span class="s2">&quot;installed&quot;</span> <span class="k">if</span> <span class="n">optional_libs</span><span class="p">[</span><span class="n">lib</span><span class="p">][</span><span class="s2">&quot;available&quot;</span><span class="p">]</span> <span class="k">else</span> <span class="s2">&quot;not installed&quot;</span>
<span class="p">)</span>
<span class="nb">print</span><span class="p">(</span>
<span class="s2">&quot;</span><span class="si">{0}</span><span class="s2">: </span><span class="se">\t</span><span class="s2"> </span><span class="si">{1}</span><span class="s2"> </span><span class="se">\t</span><span class="s2"> </span><span class="si">{2}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
<span class="n">lib</span><span class="p">,</span> <span class="n">available_string</span><span class="p">,</span> <span class="n">optional_libs</span><span class="p">[</span><span class="n">lib</span><span class="p">][</span><span class="s2">&quot;description&quot;</span><span class="p">]</span>
<span class="p">)</span>
<span class="p">)</span>
<span class="n">optional_libs</span><span class="p">[</span><span class="n">lib</span><span class="p">][</span><span class="s2">&quot;available&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="p">(</span>
<span class="n">importlib</span><span class="o">.</span><span class="n">util</span><span class="o">.</span><span class="n">find_spec</span><span class="p">(</span><span class="n">lib</span><span class="p">)</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span>
<span class="p">)</span></div>
</pre></div>

</div>
Expand Down
8 changes: 4 additions & 4 deletions _modules/mala/common/json_serializable.html
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,14 @@ <h1>Source code for mala.common.json_serializable</h1><div class="highlight"><pr

<span class="k">def</span> <span class="nf">_standard_serializer</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="n">data</span> <span class="o">=</span> <span class="p">{}</span>
<span class="n">members</span> <span class="o">=</span> <span class="n">inspect</span><span class="o">.</span><span class="n">getmembers</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span>
<span class="k">lambda</span> <span class="n">a</span><span class="p">:</span> <span class="ow">not</span> <span class="p">(</span><span class="n">inspect</span><span class="o">.</span><span class="n">isroutine</span><span class="p">(</span><span class="n">a</span><span class="p">)))</span>
<span class="n">members</span> <span class="o">=</span> <span class="n">inspect</span><span class="o">.</span><span class="n">getmembers</span><span class="p">(</span>
<span class="bp">self</span><span class="p">,</span> <span class="k">lambda</span> <span class="n">a</span><span class="p">:</span> <span class="ow">not</span> <span class="p">(</span><span class="n">inspect</span><span class="o">.</span><span class="n">isroutine</span><span class="p">(</span><span class="n">a</span><span class="p">))</span>
<span class="p">)</span>
<span class="k">for</span> <span class="n">member</span> <span class="ow">in</span> <span class="n">members</span><span class="p">:</span>
<span class="c1"># Filter out all private members, builtins, etc.</span>
<span class="k">if</span> <span class="n">member</span><span class="p">[</span><span class="mi">0</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> <span class="o">!=</span> <span class="s2">&quot;_&quot;</span><span class="p">:</span>
<span class="n">data</span><span class="p">[</span><span class="n">member</span><span class="p">[</span><span class="mi">0</span><span class="p">]]</span> <span class="o">=</span> <span class="n">member</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>
<span class="n">json_dict</span> <span class="o">=</span> <span class="p">{</span><span class="s2">&quot;object&quot;</span><span class="p">:</span> <span class="nb">type</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span><span class="p">,</span>
<span class="s2">&quot;data&quot;</span><span class="p">:</span> <span class="n">data</span><span class="p">}</span>
<span class="n">json_dict</span> <span class="o">=</span> <span class="p">{</span><span class="s2">&quot;object&quot;</span><span class="p">:</span> <span class="nb">type</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span><span class="p">,</span> <span class="s2">&quot;data&quot;</span><span class="p">:</span> <span class="n">data</span><span class="p">}</span>
<span class="k">return</span> <span class="n">json_dict</span>

<span class="nd">@classmethod</span>
Expand Down
Loading

0 comments on commit 5134fd2

Please sign in to comment.