chembfn-webui 0.6.0__tar.gz → 1.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of chembfn-webui might be problematic. Click here for more details.

Files changed (21) hide show
  1. {chembfn_webui-0.6.0 → chembfn_webui-1.1.0}/PKG-INFO +17 -2
  2. {chembfn_webui-0.6.0 → chembfn_webui-1.1.0}/README.md +15 -0
  3. {chembfn_webui-0.6.0 → chembfn_webui-1.1.0}/chembfn_webui/bin/app.py +25 -14
  4. {chembfn_webui-0.6.0 → chembfn_webui-1.1.0}/chembfn_webui/lib/version.py +1 -1
  5. {chembfn_webui-0.6.0 → chembfn_webui-1.1.0}/chembfn_webui.egg-info/PKG-INFO +17 -2
  6. {chembfn_webui-0.6.0 → chembfn_webui-1.1.0}/chembfn_webui.egg-info/requires.txt +1 -1
  7. {chembfn_webui-0.6.0 → chembfn_webui-1.1.0}/setup.py +2 -1
  8. {chembfn_webui-0.6.0 → chembfn_webui-1.1.0}/LICENSE +0 -0
  9. {chembfn_webui-0.6.0 → chembfn_webui-1.1.0}/chembfn_webui/__init__.py +0 -0
  10. {chembfn_webui-0.6.0 → chembfn_webui-1.1.0}/chembfn_webui/cache/cache_file_here.txt +0 -0
  11. {chembfn_webui-0.6.0 → chembfn_webui-1.1.0}/chembfn_webui/cache/results.csv +0 -0
  12. {chembfn_webui-0.6.0 → chembfn_webui-1.1.0}/chembfn_webui/lib/utilities.py +0 -0
  13. {chembfn_webui-0.6.0 → chembfn_webui-1.1.0}/chembfn_webui/model/base_model/place_base_model_here.txt +0 -0
  14. {chembfn_webui-0.6.0 → chembfn_webui-1.1.0}/chembfn_webui/model/lora/place_lora_folder_here.txt +0 -0
  15. {chembfn_webui-0.6.0 → chembfn_webui-1.1.0}/chembfn_webui/model/standalone_model/place_standalone_model_folder_here.txt +0 -0
  16. {chembfn_webui-0.6.0 → chembfn_webui-1.1.0}/chembfn_webui/model/vocab/place_vocabulary_file_here.txt +0 -0
  17. {chembfn_webui-0.6.0 → chembfn_webui-1.1.0}/chembfn_webui.egg-info/SOURCES.txt +0 -0
  18. {chembfn_webui-0.6.0 → chembfn_webui-1.1.0}/chembfn_webui.egg-info/dependency_links.txt +0 -0
  19. {chembfn_webui-0.6.0 → chembfn_webui-1.1.0}/chembfn_webui.egg-info/entry_points.txt +0 -0
  20. {chembfn_webui-0.6.0 → chembfn_webui-1.1.0}/chembfn_webui.egg-info/top_level.txt +0 -0
  21. {chembfn_webui-0.6.0 → chembfn_webui-1.1.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: chembfn_webui
3
- Version: 0.6.0
3
+ Version: 1.1.0
4
4
  Summary: WebUI for ChemBFN
5
5
  Home-page: https://github.com/Augus1999/ChemBFN-WebUI
6
6
  Author: Nianze A. Tao
@@ -20,7 +20,7 @@ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
20
20
  Requires-Python: >=3.11
21
21
  Description-Content-Type: text/markdown
22
22
  License-File: LICENSE
23
- Requires-Dist: bayesianflow_for_chem>=2.1.0
23
+ Requires-Dist: bayesianflow_for_chem>=2.2.2
24
24
  Requires-Dist: mol2chemfigPy3>=1.5.11
25
25
  Requires-Dist: gradio>=5.32.1
26
26
  Requires-Dist: torch>=2.7.0
@@ -83,6 +83,21 @@ For example,
83
83
  └───moses_selfies_vocab.txt
84
84
  ```
85
85
 
86
+ > Note:
87
+ >
88
+ > >The file `config.json` is automatically saved by CLI tool `Madmol` provided in `bayesianflow-for-chem` package. If you train models via Python API, you need to manually create that file for your models by filling in the tempate:
89
+ > >```json
90
+ > >{
91
+ > > "padding_index": 0,
92
+ > > "start_index": 1,
93
+ > > "end_index": 2,
94
+ > > "padding_strategy": "static",
95
+ > > "padding_length": PADDING_LENGTH,
96
+ > > "label": [LABEL_NAME_I, LABEL_NAME_II, ...],
97
+ > > "name": JOB_NAME
98
+ > >}
99
+ > >```
100
+
86
101
  If placed correctly, all these files can be seen in the "model explorer" tab.
87
102
 
88
103
  > You can use an external folder to host the models if it follows the same structure as [`chembfn_webui/model`](https://github.com/Augus1999/ChemBFN-WebUI/tree/main/chembfn_webui/model). See the next section for the method.
@@ -48,6 +48,21 @@ For example,
48
48
  └───moses_selfies_vocab.txt
49
49
  ```
50
50
 
51
+ > [!NOTE]
52
+ >
53
+ > >The file `config.json` is automatically saved by CLI tool `Madmol` provided in `bayesianflow-for-chem` package. If you train models via Python API, you need to manually create that file for your models by filling in the tempate:
54
+ > >```json
55
+ > >{
56
+ > > "padding_index": 0,
57
+ > > "start_index": 1,
58
+ > > "end_index": 2,
59
+ > > "padding_strategy": "static",
60
+ > > "padding_length": PADDING_LENGTH,
61
+ > > "label": [LABEL_NAME_I, LABEL_NAME_II, ...],
62
+ > > "name": JOB_NAME
63
+ > >}
64
+ > >```
65
+
51
66
  If placed correctly, all these files can be seen in the "model explorer" tab.
52
67
 
53
68
  > You can use an external folder to host the models if it follows the same structure as [`chembfn_webui/model`](./chembfn_webui/model). See the next section for the method.
@@ -10,7 +10,7 @@ from functools import partial
10
10
  from typing import Tuple, List, Dict, Union
11
11
 
12
12
  sys.path.append(str(Path(__file__).parent.parent))
13
- from rdkit.Chem import Draw, MolFromSmiles
13
+ from rdkit.Chem import Draw, MolFromSmiles # type: ignore
14
14
  from mol2chemfigPy3 import mol2chemfig
15
15
  import gradio as gr
16
16
  import torch
@@ -18,10 +18,10 @@ from selfies import decoder
18
18
  from bayesianflow_for_chem import ChemBFN, MLP, EnsembleChemBFN
19
19
  from bayesianflow_for_chem.data import (
20
20
  VOCAB_KEYS,
21
- AA_VOCAB_KEYS,
21
+ FASTA_VOCAB_KEYS,
22
22
  load_vocab,
23
23
  smiles2vec,
24
- aa2vec,
24
+ fasta2vec,
25
25
  split_selfies,
26
26
  )
27
27
  from bayesianflow_for_chem.tool import (
@@ -42,7 +42,8 @@ from lib.version import __version__
42
42
 
43
43
  vocabs = find_vocab()
44
44
  models = find_model()
45
- lora_selected = False # lora select flag
45
+ _lora_selected = False # lora select flag
46
+ _run_in_public = False # public flag
46
47
  cache_dir = Path(__file__).parent.parent / "cache"
47
48
 
48
49
  HTML_STYLE = gr.InputHTMLAttributes(
@@ -130,12 +131,12 @@ def select_lora(evt: gr.SelectData, prompt: str) -> str:
130
131
  :return: new prompt string
131
132
  :rtype: str
132
133
  """
133
- global lora_selected
134
- if lora_selected: # avoid double select
135
- lora_selected = False
134
+ global _lora_selected
135
+ if _lora_selected and not _run_in_public: # avoid double select
136
+ _lora_selected = False
136
137
  return prompt
137
138
  selected_lora = evt.value
138
- lora_selected = True
139
+ _lora_selected = True
139
140
  if evt.index[1] != 0:
140
141
  return prompt
141
142
  if not prompt:
@@ -246,8 +247,8 @@ def run(
246
247
  img_fn = lambda x: [Draw.MolToImage(MolFromSmiles(i), (500, 500)) for i in x]
247
248
  chemfig_fn = lambda x: [mol2chemfig(i, "-r", inline=True) for i in x]
248
249
  if token_name == "FASTA":
249
- vocab_keys = AA_VOCAB_KEYS
250
- tokeniser = aa2vec
250
+ vocab_keys = FASTA_VOCAB_KEYS
251
+ tokeniser = fasta2vec
251
252
  trans_fn = lambda x: x
252
253
  img_fn = lambda _: None # senseless to provide dumb 2D images
253
254
  chemfig_fn = lambda _: [""] # senseless to provide very long Chemfig code
@@ -344,7 +345,11 @@ def run(
344
345
  if len(sar_flag) == 1:
345
346
  sar_flag = [sar_flag[0] for _ in range(len(weights))]
346
347
  bfn = EnsembleChemBFN(base_model_dir, lora_dir, mlps, weights)
347
- y = [torch.tensor([i], dtype=torch.float32) for i in prompt_info["objective"]]
348
+ y = (
349
+ [torch.tensor([i], dtype=torch.float32) for i in prompt_info["objective"]]
350
+ if prompt_info["objective"]
351
+ else None
352
+ )
348
353
  if quantise == "on":
349
354
  bfn.quantise()
350
355
  if jited == "on":
@@ -417,7 +422,6 @@ def run(
417
422
  imgs,
418
423
  mols,
419
424
  "\n\n".join(chemfigs),
420
- # "\n".join(_message),
421
425
  gr.TextArea("\n".join(_message), label="message", lines=len(_message)),
422
426
  str(cache_dir / "results.csv"),
423
427
  )
@@ -610,12 +614,19 @@ def main() -> None:
610
614
  :return:
611
615
  :rtype: None
612
616
  """
613
- parser = argparse.ArgumentParser()
617
+ parser = argparse.ArgumentParser(
618
+ description="A web-based visualisation tool for ChemBFN method.",
619
+ epilog=f"ChemBFN WebUI {__version__}, developed in Hiroshima University by chemists for chemists. "
620
+ "Visit https://augus1999.github.io/bayesian-flow-network-for-chemistry/ for more details.",
621
+ formatter_class=argparse.ArgumentDefaultsHelpFormatter,
622
+ )
614
623
  parser.add_argument(
615
- "--public", default=False, help="open to public", action="store_true"
624
+ "-P", "--public", default=False, help="open to public", action="store_true"
616
625
  )
617
626
  parser.add_argument("-V", "--version", action="version", version=__version__)
618
627
  args = parser.parse_args()
628
+ global _run_in_public
629
+ _run_in_public = args.public
619
630
  app.launch(share=args.public, allowed_paths=[cache_dir.absolute().__str__()])
620
631
 
621
632
 
@@ -4,5 +4,5 @@
4
4
  Version info.
5
5
  """
6
6
 
7
- __version__ = "0.6.0"
7
+ __version__ = "1.1.0"
8
8
  __author__ = "Nianze A. TAO"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: chembfn_webui
3
- Version: 0.6.0
3
+ Version: 1.1.0
4
4
  Summary: WebUI for ChemBFN
5
5
  Home-page: https://github.com/Augus1999/ChemBFN-WebUI
6
6
  Author: Nianze A. Tao
@@ -20,7 +20,7 @@ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
20
20
  Requires-Python: >=3.11
21
21
  Description-Content-Type: text/markdown
22
22
  License-File: LICENSE
23
- Requires-Dist: bayesianflow_for_chem>=2.1.0
23
+ Requires-Dist: bayesianflow_for_chem>=2.2.2
24
24
  Requires-Dist: mol2chemfigPy3>=1.5.11
25
25
  Requires-Dist: gradio>=5.32.1
26
26
  Requires-Dist: torch>=2.7.0
@@ -83,6 +83,21 @@ For example,
83
83
  └───moses_selfies_vocab.txt
84
84
  ```
85
85
 
86
+ > Note:
87
+ >
88
+ > >The file `config.json` is automatically saved by CLI tool `Madmol` provided in `bayesianflow-for-chem` package. If you train models via Python API, you need to manually create that file for your models by filling in the tempate:
89
+ > >```json
90
+ > >{
91
+ > > "padding_index": 0,
92
+ > > "start_index": 1,
93
+ > > "end_index": 2,
94
+ > > "padding_strategy": "static",
95
+ > > "padding_length": PADDING_LENGTH,
96
+ > > "label": [LABEL_NAME_I, LABEL_NAME_II, ...],
97
+ > > "name": JOB_NAME
98
+ > >}
99
+ > >```
100
+
86
101
  If placed correctly, all these files can be seen in the "model explorer" tab.
87
102
 
88
103
  > You can use an external folder to host the models if it follows the same structure as [`chembfn_webui/model`](https://github.com/Augus1999/ChemBFN-WebUI/tree/main/chembfn_webui/model). See the next section for the method.
@@ -1,4 +1,4 @@
1
- bayesianflow_for_chem>=2.1.0
1
+ bayesianflow_for_chem>=2.2.2
2
2
  mol2chemfigPy3>=1.5.11
3
3
  gradio>=5.32.1
4
4
  torch>=2.7.0
@@ -35,6 +35,7 @@ long_description = long_description.replace(
35
35
  r"(./chembfn_webui/",
36
36
  r"(https://github.com/Augus1999/ChemBFN-WebUI/tree/main/chembfn_webui/",
37
37
  )
38
+ long_description = long_description.replace(r"> [!NOTE]", r"> Note:")
38
39
 
39
40
  setup(
40
41
  name="chembfn_webui",
@@ -55,7 +56,7 @@ setup(
55
56
  packages=find_packages(),
56
57
  python_requires=">=3.11",
57
58
  install_requires=[
58
- "bayesianflow_for_chem>=2.1.0",
59
+ "bayesianflow_for_chem>=2.2.2",
59
60
  "mol2chemfigPy3>=1.5.11",
60
61
  "gradio>=5.32.1",
61
62
  "torch>=2.7.0",
File without changes
File without changes