Skip to content

Commit

Permalink
Merge pull request #35 from MolecularAI/3.1.4_prep
Browse files Browse the repository at this point in the history
3.1.4
  • Loading branch information
lewismervin1 authored Oct 3, 2024
2 parents b509ff4 + 00f6609 commit 1b0c945
Show file tree
Hide file tree
Showing 115 changed files with 11,857 additions and 6,711 deletions.
55 changes: 49 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ Create conda environment with Jupyter and Install QSARtuna there:
```shell
module purge
module load Miniconda3
conda create --name my_env_with_qsartuna python=3.10.10 jupyter pip
conda create --name my_env_with_qsartuna python=3.11 jupyter pip # any python ^3.10
conda activate my_env_with_qsartuna
module purge # Just in case.
which python # Check. Should output path that contains "my_env_with_qsartuna".
python -m pip install https://github.com/MolecularAI/QSARtuna/releases/download/3.1.1/qsartuna-3.1.1.tar.gz
python -m pip install https://github.com/MolecularAI/QSARtuna/releases/download/3.1.4/qsartuna-3.1.4.tar.gz
```

## Running from Python/Jupyter Notebook
Expand Down Expand Up @@ -121,7 +121,7 @@ QSARtuna can be deployed directly from the CLI

To run commands QSARtuna uses the following syntax:
```shell
qsartuna-<optimize|build|predict|schemagen> <command>
qsartuna-<optimize|build|predict|schemagen|automl|metadata|convert> <command>
```

We can run three-step-process from command line with the following command:
Expand Down Expand Up @@ -438,12 +438,12 @@ required named arguments:

```

An example of how to run this in SCP would be:
An example of how to run this would be:

```shell
qsartuna-automl --input-data "tests/data/automl/*" --email <email>.com --user_name <user_name> \
--input-smiles-csv-column canonical --input-activity-csv-column molwt --input-task-csv-column one_taskid \
--input-initial-template examples/auto^C/config.initial.template \
--input-initial-template examples/automl/config.initial.template \
--input-retrain-template examples/automl/config.retrain.template \
--input-slurm-template examples/slurm-scripts/automl.template \
--n-cores 1 -vvv --slurm-al-pool tests/data/DRD2/subset-50/train.csv \
Expand Down Expand Up @@ -585,13 +585,15 @@ or in a new config:

## Adding machine learning algorithms to QSARtuna

NB: CustomClassificationModel and CustomRegressionModel algorithm options are now available to allow customised algorithms within QSARtuna (see tutorial for details). This new feature is experimental and should be used with caution

1.) (Optional) consider adding .py algorithm code to the `optunaz/algorithms/` directory, so this can be imported later

2.) Add the algorithm to `optunaz.config.optconfig.py`. For example, create a class among the existing algorithms like so:

```python
@dataclass
class YourAglrotihm(Algorithm):
class YourAlgorithm(Algorithm):
"""Your description goes here
"""

Expand Down Expand Up @@ -787,3 +789,44 @@ or in a new config:
}
]
}


## Converting models to QSARtuna models

QSARtuna has a CLI helper to convert models to QSARtuna models

We can perform this with the following command:

```shell
qsartuna-convert \
--input-model-file {project_folder}/sklearn_model.pkl\
--input-model-mode regression \
--output-model-path {project_folder}/qsartuna.pkl \
```

The convert CLI tool accepts the following command line arguments:

```
shell
qsartuna-convert -h
usage: qsartuna-convert [-h] --input-model-file INPUT_MODEL_FILE --input-model-mode INPUT_MODEL_MODE --output-model-path OUTPUT_MODEL_PATH [--input-json-descriptor-file INPUT_JSON_DESCRIPTOR_FILE] [--wrap-for-uncertainty]
Convert an existing sklearn(-like) model into a QSARtuna model
options:
-h, --help show this help message and exit
--input-json-descriptor-file INPUT_JSON_DESCRIPTOR_FILE
Name of input JSON file with descriptor configuration. Defaults to PrecomputedDescriptorFromFile
--wrap-for-uncertainty
Whether to wrap regression in MAPIE or classification in VennAbers Calibrated Classifiers for uncertainty support
required named arguments:
--input-model-file INPUT_MODEL_FILE
Model file name.
--input-model-mode INPUT_MODEL_MODE
Classification or regression mode for the existing model.
--output-model-path OUTPUT_MODEL_PATH
Path where to write the converted model.
```

Advanced options for the QSARtuna convert CLI tool are covered in the QSARtuna Notebook tutorial
Binary file modified docs/sphinx-builddir/doctrees/README.doctree
Binary file not shown.
Binary file modified docs/sphinx-builddir/doctrees/algorithms.doctree
Binary file not shown.
Binary file modified docs/sphinx-builddir/doctrees/deduplicator.doctree
Binary file not shown.
Binary file modified docs/sphinx-builddir/doctrees/descriptors.doctree
Binary file not shown.
Binary file modified docs/sphinx-builddir/doctrees/environment.pickle
Binary file not shown.
3,029 changes: 1,761 additions & 1,268 deletions docs/sphinx-builddir/doctrees/nbsphinx/notebooks/QSARtuna_Tutorial.ipynb

Large diffs are not rendered by default.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file modified docs/sphinx-builddir/doctrees/optunaz.config.doctree
Binary file not shown.
Binary file modified docs/sphinx-builddir/doctrees/optunaz.doctree
Binary file not shown.
Binary file modified docs/sphinx-builddir/doctrees/optunaz.utils.doctree
Binary file not shown.
Binary file modified docs/sphinx-builddir/doctrees/optunaz.utils.enums.doctree
Binary file not shown.
Binary file not shown.
Binary file modified docs/sphinx-builddir/doctrees/splitters.doctree
Binary file not shown.
2 changes: 1 addition & 1 deletion docs/sphinx-builddir/html/.buildinfo
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Sphinx build info version 1
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
config: cd8105a3e394e54ace4ef41b1def0634
config: aef108bc3193b5297b76666fcb5f2b5d
tags: 645f666f9bcd5a90fca523b33c5a78b7
116 changes: 77 additions & 39 deletions docs/sphinx-builddir/html/README.html

Large diffs are not rendered by default.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion docs/sphinx-builddir/html/_modules/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ <h1>All modules for which code is available</h1>
<ul><li><a href="optunaz/config/build_from_opt.html">optunaz.config.build_from_opt</a></li>
<li><a href="optunaz/config/buildconfig.html">optunaz.config.buildconfig</a></li>
<li><a href="optunaz/config/optconfig.html">optunaz.config.optconfig</a></li>
</ul><li><a href="optunaz/datareader.html">optunaz.datareader</a></li>
</ul><li><a href="optunaz/convert.html">optunaz.convert</a></li>
<li><a href="optunaz/datareader.html">optunaz.datareader</a></li>
<li><a href="optunaz/descriptors.html">optunaz.descriptors</a></li>
<li><a href="optunaz/evaluate.html">optunaz.evaluate</a></li>
<li><a href="optunaz/explainability.html">optunaz.explainability</a></li>
Expand Down
14 changes: 12 additions & 2 deletions docs/sphinx-builddir/html/_modules/optunaz/automl.html
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ <h1>Source code for optunaz.automl</h1><div class="highlight"><pre>
<span class="kn">import</span> <span class="nn">pandas</span> <span class="k">as</span> <span class="nn">pd</span>
<span class="kn">import</span> <span class="nn">time</span>
<span class="kn">import</span> <span class="nn">logging</span>
<span class="kn">import</span> <span class="nn">logging.config</span>
<span class="kn">import</span> <span class="nn">argparse</span>
<span class="kn">from</span> <span class="nn">datetime</span> <span class="kn">import</span> <span class="n">datetime</span><span class="p">,</span> <span class="n">timedelta</span>
<span class="kn">import</span> <span class="nn">dataclasses</span>
Expand Down Expand Up @@ -626,7 +627,13 @@ <h1>Source code for optunaz.automl</h1><div class="highlight"><pre>
<span class="k">elif</span> <span class="nb">any</span><span class="p">(</span>
<span class="p">[</span>
<span class="n">err</span> <span class="ow">in</span> <span class="n">slurm_log</span>
<span class="k">for</span> <span class="n">err</span> <span class="ow">in</span> <span class="p">[</span><span class="s2">&quot;DUE TO MEMORY&quot;</span><span class="p">,</span> <span class="s2">&quot;Bus error&quot;</span><span class="p">,</span> <span class="s2">&quot;Unable to allocate&quot;</span><span class="p">]</span>
<span class="k">for</span> <span class="n">err</span> <span class="ow">in</span> <span class="p">[</span>
<span class="s2">&quot;DUE TO MEMORY&quot;</span><span class="p">,</span>
<span class="s2">&quot;Bus error&quot;</span><span class="p">,</span>
<span class="s2">&quot;Unable to allocate&quot;</span><span class="p">,</span>
<span class="s2">&quot;oom_kill&quot;</span><span class="p">,</span>
<span class="s2">&quot;OOM Killed&quot;</span><span class="p">,</span>
<span class="p">]</span>
<span class="p">]</span>
<span class="p">):</span>
<span class="n">logging</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">slurm_name</span><span class="si">}</span><span class="s2"> memory was reached&quot;</span><span class="p">)</span>
Expand All @@ -641,6 +648,9 @@ <h1>Source code for optunaz.automl</h1><div class="highlight"><pre>
<span class="k">elif</span> <span class="s2">&quot;Adjust any of the aforementioned parameters&quot;</span> <span class="ow">in</span> <span class="n">slurm_log</span><span class="p">:</span>
<span class="n">logging</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">slurm_name</span><span class="si">}</span><span class="s2"> had splitting error&quot;</span><span class="p">)</span>
<span class="k">raise</span> <span class="n">SlurmJobSkip</span>
<span class="k">elif</span> <span class="s2">&quot;qptuna.predict.UncertaintyError&quot;</span> <span class="ow">in</span> <span class="n">slurm_log</span><span class="p">:</span>
<span class="n">logging</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">slurm_name</span><span class="si">}</span><span class="s2"> does not support uncertainty estimation&quot;</span><span class="p">)</span>
<span class="k">raise</span> <span class="n">SlurmJobSkip</span>
<span class="k">except</span> <span class="ne">FileNotFoundError</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">SlurmNoLog</span></div>

Expand Down Expand Up @@ -993,14 +1003,14 @@ <h1>Source code for optunaz.automl</h1><div class="highlight"><pre>
<span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;-v&#39;</span><span class="p">,</span> <span class="s1">&#39;--verbose&#39;</span><span class="p">,</span> <span class="n">action</span><span class="o">=</span><span class="s1">&#39;count&#39;</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="mi">0</span><span class="p">)</span>

<span class="c1"># SLURM global variables</span>
<span class="n">requiredNamed</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;--slurm-job-prefix&#39;</span><span class="p">,</span> <span class="nb">type</span><span class="o">=</span><span class="nb">str</span><span class="p">,</span> <span class="n">required</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
<span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;--slurm-req-cores&#39;</span><span class="p">,</span> <span class="nb">type</span><span class="o">=</span><span class="nb">int</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="mi">12</span><span class="p">)</span>
<span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;--slurm-req-mem&#39;</span><span class="p">,</span> <span class="nb">type</span><span class="o">=</span><span class="nb">int</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="kc">None</span><span class="p">)</span> <span class="c1"># By default, None = dynamic mem resource allocation</span>
<span class="n">requiredNamed</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;--slurm-req-partition&#39;</span><span class="p">,</span> <span class="nb">type</span><span class="o">=</span><span class="nb">str</span><span class="p">,</span> <span class="n">required</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
<span class="n">requiredNamed</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;--slurm-al-pool&#39;</span><span class="p">,</span> <span class="nb">type</span><span class="o">=</span><span class="nb">str</span><span class="p">,</span> <span class="n">required</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
<span class="n">requiredNamed</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;--slurm-al-smiles-csv-column&#39;</span><span class="p">,</span> <span class="nb">type</span><span class="o">=</span><span class="nb">str</span><span class="p">,</span> <span class="n">required</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>

<span class="c1"># dispatcher variables</span>
<span class="n">requiredNamed</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;--slurm-job-prefix&#39;</span><span class="p">,</span> <span class="nb">type</span><span class="o">=</span><span class="nb">str</span><span class="p">,</span> <span class="n">required</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
<span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;--slurm-failure-cores-increment&#39;</span><span class="p">,</span> <span class="nb">type</span><span class="o">=</span><span class="nb">int</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="mi">4</span><span class="p">)</span>
<span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;--slurm-failure-mem-increment&#39;</span><span class="p">,</span> <span class="nb">type</span><span class="o">=</span><span class="nb">int</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="mi">20</span><span class="p">)</span>
<span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;--slurm-failure-mins-increment&#39;</span><span class="p">,</span> <span class="nb">type</span><span class="o">=</span><span class="nb">int</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="mi">720</span><span class="p">)</span>
Expand Down
Loading

0 comments on commit 1b0c945

Please sign in to comment.