Skip to content

Commit 72a1c4f

Browse files
committed
Move Executor to build.py for easier dep management
1 parent 9746168 commit 72a1c4f

File tree

2 files changed

+159
-204
lines changed

2 files changed

+159
-204
lines changed

artefacts.py

Lines changed: 12 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,6 @@ class Artefact:
126126
steps: Optional[int] = 0
127127
_src: Optional[Path] = None
128128

129-
def __hash__(self) -> int:
130-
return hash(self.path)
131-
132129
@property
133130
def name(self) -> str:
134131
return self._name or self.repo.name
@@ -196,6 +193,16 @@ def build(self):
196193
os.symlink(f, self.bin / f.name)
197194

198195

196+
ALLOY = Artefact(
197+
steps=5907,
198+
repo=Repo(
199+
name="alloy",
200+
url="https://github.com/jacob-hughes/alloy",
201+
version="quickfix-stats",
202+
),
203+
)
204+
205+
199206
class Alloy(Artefact):
200207
DEFAULT_FLAGS: ClassVar[Dict[str, bool]] = {
201208
"gc-metrics": False,
@@ -206,8 +213,8 @@ class Alloy(Artefact):
206213
"gc-default-allocator": True,
207214
}
208215

209-
def __init__(self, base: Artefact, profile: "ExperimentProfile", metrics=False):
210-
self.__dict__.update(base.__dict__)
216+
def __init__(self, profile: "ExperimentProfile", metrics=False):
217+
self.__dict__.update(ALLOY.__dict__)
211218
self.profile = profile
212219
self.metrics = metrics
213220
self._config = None
@@ -293,84 +300,6 @@ def build(self):
293300
self._xpy_install()
294301

295302

296-
class Executor(Crate):
297-
suite: "BenchmarkSuite"
298-
metric: "Metric"
299-
profile: "ExperimentProfile"
300-
experiment: "Experiment"
301-
302-
def __init__(self, suite, metric, profile, experiment):
303-
self.__dict__.update(suite.crate.__dict__)
304-
self.suite = suite
305-
self.metric = metric
306-
self.profile = profile
307-
self.experiment = experiment
308-
309-
def __repr__(self):
310-
return self.profile.value
311-
312-
def __hash__(self) -> int:
313-
return hash(self.name)
314-
315-
def __lt__(self, other):
316-
return self.name < other.name
317-
318-
@property
319-
def name(self) -> str:
320-
return f"{self.suite.name}-{self.profile.full}-{self.metric.value}"
321-
322-
@property
323-
def install_prefix(self) -> Path:
324-
return BIN_DIR / self.metric.value / "benchmarks" / self.profile.path
325-
326-
@property
327-
def path(self) -> Path:
328-
return self.install_prefix / self.suite.name
329-
330-
@property
331-
def stats_dir(self) -> Path:
332-
return self.experiment.results.parent / "stats" / self.suite.name
333-
334-
@property
335-
def build_dir(self) -> Path:
336-
return (
337-
BUILD_DIR
338-
/ self.metric.value
339-
/ "benchmarks"
340-
/ self.profile.path
341-
/ self.repo.name
342-
)
343-
344-
@property
345-
def env(self):
346-
return {"RUSTC": self.alloy.path}
347-
348-
@property
349-
def alloy(self) -> "Alloy":
350-
from build import Metric
351-
352-
is_metrics = self.metric == Metric.METRICS
353-
354-
return Alloy(ALLOY, self.profile, is_metrics)
355-
356-
@prepare_build
357-
def build(self):
358-
for lib in self.suite.deps:
359-
if lib.repo:
360-
lib.repo.fetch()
361-
362-
with ExitStack() as patchstack:
363-
crates = self.suite.deps + [self]
364-
[patchstack.enter_context(c.repo.patch(self.profile)) for c in crates]
365-
self._cargo_build()
366-
target_bin = self.build_dir / "release" / super().name
367-
if not target_bin.exists():
368-
print(target_bin)
369-
raise BuildError(f"Build target does not exist")
370-
logging.info(f"Symlinking {target_bin} -> {self.path}")
371-
os.symlink(target_bin, self.path)
372-
373-
374303
@dataclass
375304
class CustomExecutor:
376305
experiment: "Experiment"
@@ -397,16 +326,6 @@ def baseline(self) -> str:
397326
return None
398327

399328

400-
ALLOY = Artefact(
401-
steps=5907,
402-
repo=Repo(
403-
name="alloy",
404-
url="https://github.com/jacob-hughes/alloy",
405-
version="quickfix-stats",
406-
),
407-
)
408-
409-
410329
# BENCHMARKS
411330

412331
SOM_REPO = Repo(

0 commit comments

Comments
 (0)