Remove dead code and wire the two-worker smoke script
This commit is contained in:
@@ -8,7 +8,7 @@ from dataclasses import dataclass, field
|
||||
from datetime import datetime, timezone
|
||||
from enum import Enum
|
||||
from types import MappingProxyType
|
||||
from typing import Any, Mapping, Sequence
|
||||
from typing import Any, Mapping
|
||||
|
||||
from ._validation import (
|
||||
canonical_json,
|
||||
|
||||
@@ -24,9 +24,7 @@ from typing import Any, Mapping, Sequence
|
||||
|
||||
from .artifacts import (
|
||||
ArtifactCollection,
|
||||
ArtifactItem,
|
||||
ArtifactRef,
|
||||
ArtifactSchema,
|
||||
Cardinality,
|
||||
CollectionKind,
|
||||
OutputManifest,
|
||||
@@ -295,8 +293,6 @@ class MapReduceWorkload:
|
||||
conformance_profiles=("core-batch-v1",),
|
||||
)
|
||||
self._exact_verifier = _EXACT_VERIFIER
|
||||
self._resources = resources
|
||||
self._execution = execution
|
||||
self._limits = limits
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
|
||||
@@ -24,7 +24,7 @@ from .artifacts import (
|
||||
OutputManifest,
|
||||
Provenance,
|
||||
)
|
||||
from .identity import ComponentRef, SDK_API_VERSION, SchemaRef
|
||||
from .identity import ComponentRef, SDK_API_VERSION
|
||||
from .execution import NetworkPolicy, ProcessModel
|
||||
from .manifest import TrustMode, WorkloadManifest
|
||||
from .plans import JobRequest, TaskSpec
|
||||
@@ -686,9 +686,6 @@ class CancellationFlag:
|
||||
def __init__(self) -> None:
|
||||
self._event = Event()
|
||||
|
||||
def cancel(self) -> None:
|
||||
self._event.set()
|
||||
|
||||
def cancelled(self) -> bool:
|
||||
return self._event.is_set()
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@ from __future__ import annotations
|
||||
|
||||
import hashlib
|
||||
import importlib.util
|
||||
import os
|
||||
from importlib import metadata
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
from typing import Mapping, Protocol, Sequence
|
||||
from typing import Mapping, Protocol
|
||||
|
||||
from .artifacts import (
|
||||
ArtifactCollection,
|
||||
|
||||
@@ -26,7 +26,6 @@ from .manifest import WorkloadManifest
|
||||
from .plans import JobRequest, ValidatedJob, WorkflowPlan
|
||||
from .protocols import (
|
||||
Planner,
|
||||
PlanningContext,
|
||||
PlanningResources,
|
||||
Reducer,
|
||||
Runner,
|
||||
|
||||
@@ -5,7 +5,6 @@ from __future__ import annotations
|
||||
from dataclasses import dataclass
|
||||
from enum import Enum
|
||||
from threading import Lock
|
||||
from types import MappingProxyType
|
||||
from typing import Mapping
|
||||
from uuid import uuid4
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@ from ._validation import (
|
||||
require_identifier,
|
||||
require_string,
|
||||
validate_version_range,
|
||||
version_in_range,
|
||||
)
|
||||
from .identity import SDK_API_VERSION
|
||||
from .execution import NetworkPolicy, ProcessModel
|
||||
|
||||
@@ -5,7 +5,7 @@ from __future__ import annotations
|
||||
import math
|
||||
import re
|
||||
from fractions import Fraction
|
||||
from typing import Mapping, Sequence
|
||||
from typing import Mapping
|
||||
|
||||
|
||||
_ANNOTATIONS = {
|
||||
|
||||
@@ -20,7 +20,6 @@ from ._validation import (
|
||||
freeze_json_mapping,
|
||||
require_exact_keys,
|
||||
require_identifier,
|
||||
require_nonnegative_int,
|
||||
require_positive_int,
|
||||
require_sha256,
|
||||
require_string,
|
||||
|
||||
@@ -15,7 +15,6 @@ from ._validation import (
|
||||
require_nonnegative_int,
|
||||
require_positive_int,
|
||||
require_schema_version,
|
||||
require_string,
|
||||
)
|
||||
from .artifacts import PortSpec
|
||||
from .execution import ExecutionProfile, NetworkPolicy, RetryPolicy
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
from dataclasses import dataclass
|
||||
from math import isfinite
|
||||
from pathlib import Path
|
||||
|
||||
@@ -5,7 +5,6 @@ from __future__ import annotations
|
||||
import logging
|
||||
from dataclasses import replace
|
||||
from dataclasses import dataclass
|
||||
from pathlib import Path
|
||||
import random
|
||||
import re
|
||||
import shutil
|
||||
|
||||
@@ -24,7 +24,6 @@ from uuid import NAMESPACE_URL, uuid5
|
||||
|
||||
from scimesh.sdk.artifacts import (
|
||||
ArtifactCollection,
|
||||
ArtifactRef,
|
||||
OutputManifest,
|
||||
Provenance,
|
||||
)
|
||||
|
||||
@@ -9,11 +9,9 @@ from .core import (
|
||||
DESCRIPTOR_NAMES,
|
||||
DescriptorRow,
|
||||
compute_descriptor_batch,
|
||||
concatenate_descriptor_shards,
|
||||
descriptor_calculator,
|
||||
validate_descriptor_names,
|
||||
write_descriptor_rows,
|
||||
write_descriptor_shards,
|
||||
)
|
||||
from .definition import (
|
||||
MAP_ENTRY_POINT,
|
||||
@@ -31,11 +29,9 @@ __all__ = [
|
||||
"DescriptorBatchWorkload",
|
||||
"DescriptorRow",
|
||||
"compute_descriptor_batch",
|
||||
"concatenate_descriptor_shards",
|
||||
"descriptor_batch_sdk_definition",
|
||||
"descriptor_calculator",
|
||||
"validate_descriptor_names",
|
||||
"workload_definition",
|
||||
"write_descriptor_rows",
|
||||
"write_descriptor_shards",
|
||||
]
|
||||
|
||||
@@ -19,7 +19,7 @@ import csv
|
||||
from dataclasses import dataclass
|
||||
from functools import lru_cache
|
||||
from pathlib import Path
|
||||
from typing import Any, Iterator, Mapping, Sequence
|
||||
from typing import Iterator, Sequence
|
||||
|
||||
from rdkit import Chem
|
||||
from rdkit.ML.Descriptors.MoleculeDescriptors import MolecularDescriptorCalculator
|
||||
@@ -229,86 +229,3 @@ def compute_descriptor_batch(
|
||||
materialized = list(rows)
|
||||
write_descriptor_rows(output_path, materialized)
|
||||
return stats.as_metrics()
|
||||
|
||||
|
||||
def write_descriptor_shards(
|
||||
input_path: Path,
|
||||
workspace: Path,
|
||||
shard_rows: int,
|
||||
) -> list[Path]:
|
||||
"""Split the input TSV into deterministic row-bounded shards with headers."""
|
||||
if (
|
||||
isinstance(shard_rows, bool)
|
||||
or not isinstance(shard_rows, int)
|
||||
or shard_rows < 1
|
||||
):
|
||||
raise ValueError("shard_rows must be a positive integer")
|
||||
paths: list[Path] = []
|
||||
current: Path | None = None
|
||||
destination = None
|
||||
writer = None
|
||||
rows_in_shard = 0
|
||||
try:
|
||||
with input_path.open("r", encoding="utf-8", newline="") as source:
|
||||
reader = csv.DictReader(source, delimiter="\t")
|
||||
fieldnames = tuple(reader.fieldnames or ())
|
||||
if not {"chembl_id", "canonical_smiles"}.issubset(set(fieldnames)):
|
||||
raise ValueError(
|
||||
"dataset is missing required columns: chembl_id, canonical_smiles"
|
||||
)
|
||||
for row in reader:
|
||||
if destination is None or rows_in_shard == shard_rows:
|
||||
if destination is not None:
|
||||
destination.close()
|
||||
current = workspace / f"shard-{len(paths)}.tsv"
|
||||
destination = current.open("w", encoding="utf-8", newline="")
|
||||
writer = csv.DictWriter(
|
||||
destination,
|
||||
fieldnames=list(fieldnames),
|
||||
delimiter="\t",
|
||||
lineterminator="\n",
|
||||
)
|
||||
writer.writeheader()
|
||||
paths.append(current)
|
||||
rows_in_shard = 0
|
||||
assert writer is not None
|
||||
writer.writerow(row)
|
||||
rows_in_shard += 1
|
||||
finally:
|
||||
if destination is not None:
|
||||
destination.close()
|
||||
if not paths:
|
||||
raise ValueError("dataset has no data rows")
|
||||
return paths
|
||||
|
||||
|
||||
def concatenate_descriptor_shards(
|
||||
partial_paths: Sequence[Path],
|
||||
output_path: Path,
|
||||
) -> dict[str, int]:
|
||||
"""Merge shard partial CSVs by shard index with exactly one header.
|
||||
|
||||
Every partial is a full CSV with the same header. The first partial is
|
||||
copied verbatim; each later partial contributes only its data rows, so the
|
||||
merged file is byte-identical to the single-process reference for the same
|
||||
input rows.
|
||||
"""
|
||||
if not partial_paths:
|
||||
raise ValueError("descriptor reducer requires at least one partial")
|
||||
output_path.parent.mkdir(parents=True, exist_ok=True)
|
||||
rows_emitted = 0
|
||||
with output_path.open("w", encoding="utf-8", newline="") as destination:
|
||||
for index, partial in enumerate(partial_paths):
|
||||
with partial.open("r", encoding="utf-8", newline="") as source:
|
||||
for line_index, line in enumerate(source):
|
||||
if line_index == 0:
|
||||
if index > 0:
|
||||
continue
|
||||
if line.rstrip("\r\n") != ",".join(DESCRIPTOR_COLUMNS):
|
||||
raise ValueError(
|
||||
"partial descriptor CSV has an invalid header"
|
||||
)
|
||||
destination.write(line)
|
||||
if line_index > 0:
|
||||
rows_emitted += 1
|
||||
return {"partial_count": len(partial_paths), "rows_emitted": rows_emitted}
|
||||
|
||||
@@ -8,7 +8,6 @@ workload definition packages (``search``, ``graph``, ``descriptors``) and the
|
||||
from __future__ import annotations
|
||||
|
||||
import hashlib
|
||||
import os
|
||||
import platform
|
||||
import sys
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@ from __future__ import annotations
|
||||
|
||||
import csv
|
||||
from pathlib import Path
|
||||
from typing import Mapping
|
||||
|
||||
from rdkit import Chem
|
||||
from rdkit.Chem import Descriptors
|
||||
|
||||
@@ -12,7 +12,7 @@ from typing import Any
|
||||
|
||||
from rdkit import DataStructs
|
||||
|
||||
from scimesh.chemistry.dataset import DatasetStats, MoleculeRecord, iter_valid_molecules
|
||||
from scimesh.chemistry.dataset import DatasetStats, iter_valid_molecules
|
||||
from scimesh.chemistry.fingerprints import fingerprint
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user