How molecularai/reinvent works
Project Type and Purpose
• This is an open-source, Python-based command-line tool (REINVENT 3.2) for molecular generative modeling.
• It provides multiple “running modes” (reinforcement learning, curriculum learning, transfer learning, sampling, scoring, create_model, validation), each orchestrated by a runner.
• It leverages key patterns (Strategy, Factory/Builder, DTOs) to allow extensibility and configuration via JSON templates and a Conda environment.
File Structure Analysis
• Top level:
• input.py – entry point parsing JSON and invoking the manager
• manager.py – coordinates loading of config and dispatch to the correct constructor
• configs/ – holds example and user configuration JSONs
• running_modes/ – core domain modules, each subfolder implements one mode
• constructors/ – Factory classes that, given a running mode name, build the correct runner + dependencies
• utils/ – shared utilities (configuration parsing, generic helpers)
• main_test.py + unittest_reinvent/ – test harness, fixtures, unit tests
• running_modes/<mode> structure:
• actions/ – low-level steps (sample, train, evaluate)
• learning_strategy/, production_strategy/, scoring_strategy/, curriculum_strategy/ – Strategy pattern implementations
• dto/ – data transfer objects carrying results between components
• logging/ – infrastructure for local/remote/TensorBoard logging
• core_<mode>.py or <mode>.py – central orchestration for that mode
README Insights
• Configuration-driven: user provides a JSON file, invoked as “python input.py my_mode.json”.
• Outputs logs to file system and TensorBoard.
• Requires CUDA GPU and optional OpenEye license for certain scoring modes.
• Tests exercise each mode by instantiating runners via config JSON.
a. Main Components
• CLI Layer: input.py
• Configuration Loader: manager.py + utils/configuration.py
• Constructor Layer: constructors/*_mode_constructor.py
• Runner Layer: running_modes/<mode>/… – orchestrates mode logic
• Sub-modules within each mode:
– Actions (sample, train, evaluate)
– Strategies (learning, production, scoring, curriculum)
– DTOs (payload objects between actions/strategies)
– Logging (console, local files, remote/TensorBoard)
• External Services/Libs:
– CUDA/GPU
– TensorBoard
– OpenEye (optional)
– lib_invent C++ backend, link_invent binding
b. Interactions
• User invokes CLI → Configuration Loader reads JSON → Manager picks correct Constructor → Constructor instantiates Runner with configured strategies, actions, loggers → Runner executes sequence of actions via strategies, passing DTOs → Loggers capture metrics and write to local fs / TensorBoard / remote endpoint.
c. Architectural Patterns
• Strategy pattern for learning, production, scoring, curriculum
• Factory/Builder pattern in constructors for decoupled instantiation
• DTOs for decoupling data exchange
• Layered architecture (Presentation → Configuration → Orchestration → Domain → Infrastructure)
d. Key Technologies and Frameworks
• Python 3.7, Conda environment (reinvent.yml)
• GPU/CUDA
• TensorBoard
• Optional OpenEye license for proprietary scoring
• C++ backends (lib_invent, link_invent)