deeporigin.drug_discovery.konnektor¶
Synchronous ligand network generation with the Konnektor platform tool.
Attributes¶
Classes¶
Konnektor
¶
Bases: Execution, SyncExecutableMixin
Generate a ligand network with Konnektor and return a :class:KonnektorResult.
Konnektor accepts at least two ligands. Each ligand is synced before execution
so the platform can receive either a ligand entity ID or a remote SDF path.
The synchronous :meth:run method returns resolved ligand pairs, connectivity,
and inline visualization HTML suitable for :class:~deeporigin.drug_discovery.rbfe.RBFE.
Attributes:
| Name | Type | Description |
|---|---|---|
ligands |
LigandSet
|
Ligands to connect. |
network_type |
KonnektorNetworkType
|
Network topology planner, one of |
Attributes¶
USER_LOG_COLUMNS
class-attribute
¶
USER_LOG_COLUMNS: list[str] = [
"log_level",
"tool_key",
"timestamp",
"message",
]
cost
property
¶
cost: float | None
Actual cost in dollars, set after execution completes.
This property cannot be set manually.
estimate
property
¶
estimate: float | None
Cost estimate in dollars, populated when the platform returns a quotation.
Set after run(quote=True), start(quote=True), or any call with
approve_amount=0. None until a quotation result is received.
This property cannot be set manually.
runtime
property
¶
runtime: float | None
Seconds from DTO startedAt to completedAt or current UTC time.
Uses :attr:dto (same shape as client.executions.get). When
completedAt is present, it is the end time; otherwise the end time is
datetime.now(timezone.utc). Returns None if there is no DTO or
startedAt is missing or empty.
tool_key
class-attribute
instance-attribute
¶
tool_key: str = TOOL_KEYS_AND_VERSIONS["konnektor"][
"tool_key"
]
Methods:¶
confirm
¶
confirm() -> None
Confirm a quoted tools execution on the platform.
Requires :attr:id and status equal to "Quoted". Uses
:meth:~deeporigin.platform.executions.Executions.confirm with
:data:~deeporigin.utils.constants.TOOL_EXECUTION_POST_TIMEOUT_SECONDS
(10 minutes) and retry=False, then applies the returned DTO via
:meth:update_from_dto so status, :attr:cost, and :attr:dto
reflect the platform response. For direct (blocking) tools the response
is typically terminal (Completed); for async tools it may be
Created or Running — call :meth:sync until the job finishes.
Raises:
| Type | Description |
|---|---|
ValueError
|
If there is no platform execution id or status is not
|
duplicate
¶
duplicate(
*, client: DeepOriginClient | None = None
) -> Self
Create a fresh copy with the same configuration but no execution state.
Useful after from_id() to re-run the same calculation. The
returned instance has no id, status, estimate, or
cost — it is ready for run() / start().
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
client
|
DeepOriginClient | None
|
Optional API client for the new instance. Falls back to the current instance's client. |
None
|
Returns:
| Type | Description |
|---|---|
Self
|
A new instance sharing the same domain-specific configuration. |
from_dto
classmethod
¶
from_dto(
dto: dict[str, Any],
*,
client: DeepOriginClient | None = None
) -> Self
Construct an instance from an execution DTO returned by the platform API.
Creates a bare instance via object.__new__ (bypassing __init__)
and populates common tools execution fields (including :attr:name from
the DTO name field) via :meth:update_from_dto. If the instance
defines _init_after_from_dto
(e.g. :class:~deeporigin.drug_discovery.notebook_watch_mixin.NotebookWatchMixin),
it is called after common fields are set. Subclasses should call
super().from_dto() then rehydrate domain-specific fields from
instance._dto["userInputs"].
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dto
|
dict[str, Any]
|
Execution payload (same shape as |
required |
client
|
DeepOriginClient | None
|
Optional API client. Uses the default if not provided. |
None
|
Returns:
| Type | Description |
|---|---|
Self
|
A partially-hydrated instance with common fields populated. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If |
ValueError
|
If the DTO |
from_id
classmethod
¶
from_id(
id: str, *, client: DeepOriginClient | None = None
) -> Self
Construct an instance from an existing platform execution ID.
Fetches the execution DTO via client.executions.get and delegates to
:meth:from_dto. Concrete subclasses override :meth:from_dto to attach
domain state from userInputs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
str
|
Platform execution ID. |
required |
client
|
DeepOriginClient | None
|
Optional API client. Uses the default if not provided. |
None
|
Returns:
| Type | Description |
|---|---|
Self
|
A partially-hydrated instance with common fields populated. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If |
from_last_run
classmethod
¶
from_last_run(
*, client: DeepOriginClient | None = None
) -> Self
Construct an instance from the most recently created execution of this tool.
Calls client.executions.list with tool_key, order set to
:data:~deeporigin.utils.constants.EXECUTION_LIST_ORDER_CREATED_DESC,
and page_size=1, then delegates to :meth:from_dto. Concrete
subclasses inherit this method; domain state is restored via their
from_dto overrides.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
client
|
DeepOriginClient | None
|
Optional API client. Uses the default if not provided. |
None
|
Returns:
| Type | Description |
|---|---|
Self
|
A partially-hydrated instance for the newest execution by |
Self
|
|
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If |
ValueError
|
If no executions exist for this tool type. |
get_results
¶
get_results(**kwargs: Any) -> Any
Fetch results for this execution from the data platform.
Thin wrapper around :meth:deeporigin.platform.results.Results.get
scoped to this execution's compute_job_id. Subclasses that need
result-type-specific filtering (e.g. poses, prepared systems) should
override this method and call the appropriate Results wrapper
directly rather than teaching this base method about those filters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Any
|
Forwarded verbatim to
:meth: |
{}
|
Returns:
| Type | Description |
|---|---|
Any
|
Result-explorer response dict with |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the execution has no ID yet. |
get_user_logs
¶
get_user_logs(
*,
limit: int | None = None,
offset: int | None = None,
select: list[str] | None = None,
with_total_count: bool = False
) -> DataFrame | None
Search data-platform user_logs rows for this execution.
Uses :meth:deeporigin.platform.user_logs.UserLogs.search with this
execution's id (tools executionId), stored as execution_id on
user_logs rows — the same string passed to :meth:get_results as
compute_job_id.
When no execution id is assigned yet, returns None without calling
the API.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
limit
|
int | None
|
Max rows to return (forwarded to |
None
|
offset
|
int | None
|
Skip offset (forwarded). |
None
|
select
|
list[str] | None
|
Columns to select (forwarded). |
None
|
with_total_count
|
bool
|
Request total count from the server (forwarded). |
False
|
Returns:
| Type | Description |
|---|---|
DataFrame | None
|
A DataFrame with columns |
DataFrame | None
|
and |
DataFrame | None
|
|
DataFrame | None
|
if this instance has no execution id yet or the client has no |
DataFrame | None
|
|
list
classmethod
¶
list(
*,
client: DeepOriginClient | None = None,
status: list[str] | None = None
) -> list[Self]
List executions of this tool type from the platform.
Calls client.executions.list(fetch_all_pages=True, tool_key=...),
then builds instances via :meth:from_dto. Optional status filters
hydrated instances by instance.status.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
client
|
DeepOriginClient | None
|
Optional API client. Uses the default if not provided. |
None
|
status
|
list[str] | None
|
Optional list of statuses to keep (membership test). |
None
|
Returns:
| Type | Description |
|---|---|
list[Self]
|
Instances of this class, one per matching execution. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If |
run
¶
run(
*,
quote: bool = False,
approve_amount: int | None = None
) -> KonnektorResult | None
Run Konnektor synchronously and return the network result.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
quote
|
bool
|
Shorthand for |
False
|
approve_amount
|
int | None
|
Spend cap forwarded to the platform as |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
A |
KonnektorResult | None
|
class: |
Raises:
| Type | Description |
|---|---|
DeepOriginException
|
If the execution does not succeed or the response
does not contain a valid v0.5 |
sync
¶
sync() -> None
Fetch the latest tools execution from the platform and refresh fields.
Calls client.executions.get for :attr:id and applies the response
with :meth:update_from_dto. Use when the job may have changed outside
this process (for example after submission from the web UI), to poll
lifecycle state, or to refresh an instance built from an older DTO.
Available on sync-only and async execution types alike.
If executions.get returns a falsy value, this instance is left
unchanged.
Raises:
| Type | Description |
|---|---|
ValueError
|
If this instance has no execution id yet. |
NotImplementedError
|
If |
ValueError
|
If the returned DTO |
update_from_dto
¶
update_from_dto(dto: dict[str, Any]) -> None
Apply tools execution fields from dto onto this instance.
Updates id, pricing, lifecycle fields, and _dto the same
way as :meth:from_dto for a newly created instance. Use after a live
executions.create / sync() response to refresh state without
constructing a new object (domain inputs on self are unchanged).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dto
|
dict[str, Any]
|
Execution payload (same shape as |
required |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If |
ValueError
|
If the DTO |
wait
¶
wait(
*,
poll_interval: float = 5.0,
timeout: float | None = None
) -> dict[str, Any] | None
Block until this execution reaches a terminal state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
poll_interval
|
float
|
Seconds to sleep between polling cycles. |
5.0
|
timeout
|
float | None
|
Maximum total seconds to wait. If |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, Any] | None
|
The latest execution DTO, or |
Raises:
| Type | Description |
|---|---|
ValueError
|
If this instance has no execution id yet. |
TimeoutError
|
If |
KonnektorResult
dataclass
¶
Result of a successful Konnektor synchronous run.
Attributes:
| Name | Type | Description |
|---|---|---|
pairs |
list[tuple[Ligand, Ligand]]
|
Resolved ligand pairs from the planned network edges. |
is_connected |
bool
|
Whether the generated network is fully connected. |
network_html |
str
|
Inline interactive network visualization HTML. |