strategist

alchemiscale.strategist.service — strategist service

class alchemiscale.strategist.service.StrategistService(settings: StrategistSettings)

Bases: object

Service for executing strategies on AlchemicalNetworks.

This service runs in an infinite loop, periodically: 1. Querying for strategies ready for execution 2. Executing strategies in parallel using ProcessPoolExecutor 3. Converting strategy weights to task counts 4. Creating/cancelling tasks as needed 5. Updating strategy state

close()

Close the Neo4j driver for this service instance.

cycle()

Perform one iteration of strategy execution.

start()

Start the Strategist service.

stop()

Stop the strategist service.

alchemiscale.strategist.service.execute_strategy_worker(network_sk: ScopedKey, strategy_state: StrategyState, settings: StrategistSettings) StrategyState

Standalone worker function for executing strategies in ProcessPoolExecutor.

This function creates its own StrategistService instance to avoid serialization issues with bound methods and maintains cache functionality per worker process.

Parameters:
  • network_sk (ScopedKey) – The scoped key of the network to execute strategy for

  • strategy_state (StrategyState) – The current state of the strategy

  • settings (StrategistSettings) – Settings to instantiate the StrategistService

Returns:

Updated strategy state after execution

Return type:

StrategyState