Skip to content

Commit c767693

Browse files
committed
Update logging and fix #22
1 parent bc2ec8d commit c767693

12 files changed

Lines changed: 5620 additions & 4467 deletions

docs/source/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
### Removed
1111

1212
- Python 3.8 compatibility. The dependency `meeko @ git+https://github.com/ale94mleon/meeko.git@main` requires a higher Python version because building it requires `setuptools>=77.0.0`, which is not compatible with Python 3.8.
13+
- Environmental variable `MOLDRUG_VERBOSE`
1314

1415
### Changed
1516

1617
- CLI has subspaces: `run` and `constraintconf`. The syntax `moldrug config.yml` changed to `moldrug run config.yml` and `constraintconf_moldrug ...` to `moldrug constraintconf ...`.
1718
- `GA` and `Local` now lies on the `opt` module. they can also be imported directly. E.g. `from moldrug import GA`.
1819
- Use logging instead of print.
20+
- Now the user needs to define the desired level for the logging as well the format: `logging.basicConfig(level=logging.INFO, format='%(asctime)s: %(name)s: %(levelname)s: %(message)s')` is recommended.
21+
- The logging level at CLI is defined by the `verbose` (`V`) flag.
1922
- Move from `.rst` to `.md` on the documentation.
2023
- Update installation instructions.
2124
- Versioning: `Major.Minor.Patch` --> `Major.Minnor.Patch.postX` it helps to distinguish commits that are not yet included on the `Patch`.

docs/source/notebooks/advance-topics.ipynb

Lines changed: 3140 additions & 3070 deletions
Large diffs are not rendered by default.

docs/source/notebooks/constraint-docking.ipynb

Lines changed: 357 additions & 879 deletions
Large diffs are not rendered by default.

docs/source/notebooks/how-to.ipynb

Lines changed: 52 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
},
2020
{
2121
"cell_type": "code",
22-
"execution_count": 1,
22+
"execution_count": 5,
2323
"metadata": {},
2424
"outputs": [],
2525
"source": [
@@ -33,7 +33,7 @@
3333
},
3434
{
3535
"cell_type": "code",
36-
"execution_count": 2,
36+
"execution_count": 6,
3737
"metadata": {},
3838
"outputs": [],
3939
"source": [
@@ -44,7 +44,7 @@
4444
},
4545
{
4646
"cell_type": "code",
47-
"execution_count": 3,
47+
"execution_count": 7,
4848
"metadata": {},
4949
"outputs": [],
5050
"source": [
@@ -54,7 +54,7 @@
5454
},
5555
{
5656
"cell_type": "code",
57-
"execution_count": 4,
57+
"execution_count": 8,
5858
"metadata": {},
5959
"outputs": [],
6060
"source": [
@@ -75,7 +75,7 @@
7575
},
7676
{
7777
"cell_type": "code",
78-
"execution_count": 5,
78+
"execution_count": 9,
7979
"metadata": {},
8080
"outputs": [
8181
{
@@ -101,14 +101,14 @@
101101
},
102102
{
103103
"cell_type": "code",
104-
"execution_count": 6,
104+
"execution_count": 10,
105105
"metadata": {},
106106
"outputs": [
107107
{
108108
"name": "stdout",
109109
"output_type": "stream",
110110
"text": [
111-
"usage: moldrug run [-h] [-f [FITNESS]] [-c] [-V [VERBOSE]] yaml_file\n",
111+
"usage: moldrug run [-h] [-f [FITNESS]] [-c] [-V] yaml_file\n",
112112
"\n",
113113
"🚀 Main moldrug runner\n",
114114
"\n",
@@ -128,7 +128,7 @@
128128
" located in the working directory. This option is only\n",
129129
" compatible with moldrug.opt.GA; otherwise, a\n",
130130
" RuntimeError will be raised.\n",
131-
" -V [VERBOSE], --verbose [VERBOSE]\n"
131+
" -V, --verbose Increase verbosity (-V for INFO, -VV for DEBUG)\n"
132132
]
133133
}
134134
],
@@ -159,7 +159,7 @@
159159
},
160160
{
161161
"cell_type": "code",
162-
"execution_count": 7,
162+
"execution_count": 11,
163163
"metadata": {},
164164
"outputs": [
165165
{
@@ -202,7 +202,7 @@
202202
},
203203
{
204204
"cell_type": "code",
205-
"execution_count": 8,
205+
"execution_count": 12,
206206
"metadata": {},
207207
"outputs": [
208208
{
@@ -219,7 +219,7 @@
219219
" 'deffnm']"
220220
]
221221
},
222-
"execution_count": 8,
222+
"execution_count": 12,
223223
"metadata": {},
224224
"output_type": "execute_result"
225225
}
@@ -325,7 +325,7 @@
325325
},
326326
{
327327
"cell_type": "code",
328-
"execution_count": 9,
328+
"execution_count": 13,
329329
"metadata": {},
330330
"outputs": [
331331
{
@@ -334,7 +334,7 @@
334334
"['crem.db.gz', 'config.yml', 'crem.db']"
335335
]
336336
},
337-
"execution_count": 9,
337+
"execution_count": 13,
338338
"metadata": {},
339339
"output_type": "execute_result"
340340
}
@@ -390,34 +390,34 @@
390390
},
391391
{
392392
"cell_type": "code",
393-
"execution_count": 10,
393+
"execution_count": 14,
394394
"metadata": {},
395395
"outputs": [
396396
{
397397
"name": "stdout",
398398
"output_type": "stream",
399399
"text": [
400-
"2025-09-28 10:03:27,045 - moldrug - INFO - Started at Sun Sep 28 10:03:27 2025\n",
401-
"2025-09-28 10:03:27,045 - moldrug - INFO - You are using moldrug: 3.7.3.post34.dev0\n",
400+
"2025-09-28 19:30:09,521 - INFO - moldrug.cli - Started at Sun Sep 28 19:30:09 2025\n",
401+
"2025-09-28 19:30:09,521 - INFO - moldrug.cli - You are using moldrug: 3.7.3.post35.dev0\n",
402402
"\n",
403-
"2025-09-28 10:03:27,045 - moldrug - INFO - MoldrugRunHelper(yaml_file=config.yml, fitness=None, continuation=False, verbose=False)\n",
403+
"2025-09-28 19:30:09,521 - INFO - moldrug.cli - MoldrugRunHelper(yaml_file=config.yml, fitness=None, continuation=False, verbose=2)\n",
404404
"\n",
405405
"\n",
406-
"2025-09-28 10:03:29,471 - moldrug - INFO - Calculating cost function...\n",
407-
"100%|█████████████████████████████████████████████| 2/2 [00:06<00:00, 3.00s/it]\n",
408-
"2025-09-28 10:03:35,493 - moldrug - INFO - Finished at Sun Sep 28 10:03:35 2025.\n",
406+
"2025-09-28 19:30:11,871 - INFO - moldrug.opt - Calculating cost function...\n",
407+
"100%|█████████████████████████████████████████████| 2/2 [00:05<00:00, 2.69s/it]\n",
408+
"2025-09-28 19:30:17,272 - INFO - moldrug.opt - Finished at Sun Sep 28 19:30:17 2025.\n",
409409
"\n",
410-
"2025-09-28 10:03:35,502 - moldrug - INFO - File local_pop.sdf was createad!\n"
410+
"2025-09-28 19:30:17,282 - INFO - moldrug.utils - File local_pop.sdf was createad!\n"
411411
]
412412
}
413413
],
414414
"source": [
415-
"! moldrug run config.yml"
415+
"! moldrug run config.yml -VV"
416416
]
417417
},
418418
{
419419
"cell_type": "code",
420-
"execution_count": 11,
420+
"execution_count": 15,
421421
"metadata": {},
422422
"outputs": [
423423
{
@@ -426,7 +426,7 @@
426426
"['local_result.pbz2', 'crem.db.gz', 'local_pop.sdf', 'config.yml', 'crem.db']"
427427
]
428428
},
429-
"execution_count": 11,
429+
"execution_count": 15,
430430
"metadata": {},
431431
"output_type": "execute_result"
432432
}
@@ -487,7 +487,7 @@
487487
},
488488
{
489489
"cell_type": "code",
490-
"execution_count": 12,
490+
"execution_count": 16,
491491
"metadata": {},
492492
"outputs": [
493493
{
@@ -501,7 +501,7 @@
501501
" 'config_custom_fitness.yml']"
502502
]
503503
},
504-
"execution_count": 12,
504+
"execution_count": 16,
505505
"metadata": {},
506506
"output_type": "execute_result"
507507
}
@@ -519,7 +519,7 @@
519519
},
520520
{
521521
"cell_type": "code",
522-
"execution_count": 13,
522+
"execution_count": 17,
523523
"metadata": {},
524524
"outputs": [
525525
{
@@ -534,7 +534,7 @@
534534
" 'config_custom_fitness.yml']"
535535
]
536536
},
537-
"execution_count": 13,
537+
"execution_count": 17,
538538
"metadata": {},
539539
"output_type": "execute_result"
540540
}
@@ -586,34 +586,34 @@
586586
},
587587
{
588588
"cell_type": "code",
589-
"execution_count": 14,
589+
"execution_count": 18,
590590
"metadata": {},
591591
"outputs": [
592592
{
593593
"name": "stdout",
594594
"output_type": "stream",
595595
"text": [
596-
"2025-09-28 10:03:37,081 - moldrug - INFO - Started at Sun Sep 28 10:03:37 2025\n",
597-
"2025-09-28 10:03:37,081 - moldrug - INFO - You are using moldrug: 3.7.3.post34.dev0\n",
596+
"2025-09-28 19:30:18,738 - INFO - moldrug.cli - Started at Sun Sep 28 19:30:18 2025\n",
597+
"2025-09-28 19:30:18,738 - INFO - moldrug.cli - You are using moldrug: 3.7.3.post35.dev0\n",
598598
"\n",
599-
"2025-09-28 10:03:37,081 - moldrug - INFO - MoldrugRunHelper(yaml_file=config_custom_fitness.yml, fitness=MyCustomFitness.py, continuation=False, verbose=False)\n",
599+
"2025-09-28 19:30:18,738 - INFO - moldrug.cli - MoldrugRunHelper(yaml_file=config_custom_fitness.yml, fitness=MyCustomFitness.py, continuation=False, verbose=2)\n",
600600
"\n",
601601
"\n",
602-
"2025-09-28 10:03:39,741 - moldrug - INFO - Calculating cost function...\n",
603-
"100%|█████████████████████████████████████████████| 2/2 [00:04<00:00, 2.39s/it]\n",
604-
"2025-09-28 10:03:44,543 - moldrug - INFO - Finished at Sun Sep 28 10:03:44 2025.\n",
602+
"2025-09-28 19:30:21,216 - INFO - moldrug.opt - Calculating cost function...\n",
603+
"100%|█████████████████████████████████████████████| 2/2 [00:04<00:00, 2.48s/it]\n",
604+
"2025-09-28 19:30:26,202 - INFO - moldrug.opt - Finished at Sun Sep 28 19:30:26 2025.\n",
605605
"\n",
606-
"2025-09-28 10:03:44,547 - moldrug - INFO - File local_pop.sdf was createad!\n"
606+
"2025-09-28 19:30:26,207 - INFO - moldrug.utils - File local_pop.sdf was createad!\n"
607607
]
608608
}
609609
],
610610
"source": [
611-
"! moldrug run config_custom_fitness.yml --fitness MyCustomFitness.py"
611+
"! moldrug run config_custom_fitness.yml --fitness MyCustomFitness.py -VV"
612612
]
613613
},
614614
{
615615
"cell_type": "code",
616-
"execution_count": 15,
616+
"execution_count": 19,
617617
"metadata": {},
618618
"outputs": [
619619
{
@@ -630,7 +630,7 @@
630630
" 'config_custom_fitness.yml']"
631631
]
632632
},
633-
"execution_count": 15,
633+
"execution_count": 19,
634634
"metadata": {},
635635
"output_type": "execute_result"
636636
}
@@ -641,7 +641,7 @@
641641
},
642642
{
643643
"cell_type": "code",
644-
"execution_count": 16,
644+
"execution_count": 20,
645645
"metadata": {},
646646
"outputs": [
647647
{
@@ -665,16 +665,16 @@
665665
},
666666
{
667667
"cell_type": "code",
668-
"execution_count": 17,
668+
"execution_count": 21,
669669
"metadata": {},
670670
"outputs": [
671671
{
672672
"data": {
673673
"text/plain": [
674-
"<moldrug.opt.Local at 0x17e80e380>"
674+
"<moldrug.opt.Local at 0x31a960460>"
675675
]
676676
},
677-
"execution_count": 17,
677+
"execution_count": 21,
678678
"metadata": {},
679679
"output_type": "execute_result"
680680
}
@@ -687,7 +687,7 @@
687687
},
688688
{
689689
"cell_type": "code",
690-
"execution_count": 18,
690+
"execution_count": 22,
691691
"metadata": {},
692692
"outputs": [
693693
{
@@ -696,7 +696,7 @@
696696
"<function CustomMoldrugFitness.MyAwesomeCost(Individual: moldrug.utils.Individual, wd: str = '.vina_jobs', vina_executable: str = 'vina', receptor_pdbqt_path: str = None, boxcenter: List[float] = None, boxsize: List[float] = None, exhaustiveness: int = 8, ncores: int = 1, num_modes: int = 1)>"
697697
]
698698
},
699-
"execution_count": 18,
699+
"execution_count": 22,
700700
"metadata": {},
701701
"output_type": "execute_result"
702702
}
@@ -717,7 +717,7 @@
717717
},
718718
{
719719
"cell_type": "code",
720-
"execution_count": 19,
720+
"execution_count": 23,
721721
"metadata": {},
722722
"outputs": [],
723723
"source": [
@@ -775,7 +775,7 @@
775775
},
776776
{
777777
"cell_type": "code",
778-
"execution_count": 20,
778+
"execution_count": 24,
779779
"metadata": {},
780780
"outputs": [],
781781
"source": [
@@ -796,7 +796,7 @@
796796
},
797797
{
798798
"cell_type": "code",
799-
"execution_count": 21,
799+
"execution_count": 25,
800800
"metadata": {},
801801
"outputs": [],
802802
"source": [
@@ -833,39 +833,16 @@
833833
},
834834
{
835835
"cell_type": "code",
836-
"execution_count": 22,
836+
"execution_count": 26,
837837
"metadata": {},
838838
"outputs": [
839839
{
840840
"name": "stdout",
841841
"output_type": "stream",
842842
"text": [
843-
"2025-09-28 10:03:48,921 - moldrug - INFO - Creating the first population with 20 members:\n",
844-
"100%|███████████████████████████████████████████| 20/20 [00:03<00:00, 5.83it/s]\n",
845-
"2025-09-28 10:03:52,640 - moldrug - INFO - Initial Population: Best Individual: Individual(idx = 5, smiles = C=CC(C#N)OC(=O)CCC, cost = 0.013639271647462481)\n",
846-
"2025-09-28 10:03:52,640 - moldrug - INFO - Acceptance rate: 20 / 20\n",
847-
"\n",
848-
"2025-09-28 10:04:46,027 - moldrug - INFO - Evaluating generation 1 / 2:\n",
849-
"100%|███████████████████████████████████████████| 20/20 [00:03<00:00, 6.23it/s]\n",
850-
"2025-09-28 10:04:49,475 - moldrug - INFO - Generation 1: Best Individual: Individual(idx = 5, smiles = C=CC(C#N)OC(=O)CCC, cost = 0.013639271647462481)\n",
851-
"2025-09-28 10:04:49,475 - moldrug - INFO - Acceptance rate: 7 / 20\n",
852-
"\n",
853-
"2025-09-28 10:05:42,998 - moldrug - INFO - Evaluating generation 2 / 2:\n",
854-
"100%|███████████████████████████████████████████| 20/20 [00:03<00:00, 6.03it/s]\n",
855-
"2025-09-28 10:05:46,607 - moldrug - INFO - Generation 2: Best Individual: Individual(idx = 5, smiles = C=CC(C#N)OC(=O)CCC, cost = 0.013639271647462481)\n",
856-
"2025-09-28 10:05:46,607 - moldrug - INFO - Acceptance rate: 6 / 20\n",
857-
"\n",
858-
"2025-09-28 10:05:46,607 - moldrug - INFO - \t\t=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+\n",
859-
"\n",
860-
"2025-09-28 10:05:46,607 - moldrug - INFO - The simulation finished successfully after 2 generations witha population of 20 individuals. A total number of 60 Individuals were seen during the simulation.\n",
861-
"2025-09-28 10:05:46,607 - moldrug - INFO - Initial Individual: Individual(idx = 0, smiles = CCCC(=O)OCCN, cost = 0.19688061076437202)\n",
862-
"2025-09-28 10:05:46,607 - moldrug - INFO - Final Individual: Individual(idx = 5, smiles = C=CC(C#N)OC(=O)CCC, cost = 0.013639271647462481)\n",
863-
"2025-09-28 10:05:46,607 - moldrug - INFO - The cost function dropped in 0.18324133911690954 units.\n",
864-
"2025-09-28 10:05:46,607 - moldrug - INFO - \t\t=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+\n",
865-
"\n",
866-
"2025-09-28 10:05:46,607 - moldrug - INFO - Total time (2 generations): 120.52 (s).\n",
867-
"Finished at Sun Sep 28 10:05:46 2025.\n",
868-
"\n"
843+
"100%|███████████████████████████████████████████| 20/20 [00:03<00:00, 6.42it/s]\n",
844+
"100%|███████████████████████████████████████████| 20/20 [00:03<00:00, 5.74it/s]\n",
845+
"100%|███████████████████████████████████████████| 20/20 [00:03<00:00, 5.95it/s]\n"
869846
]
870847
}
871848
],

0 commit comments

Comments
 (0)