Skip to content

Commit c4896be

Browse files
author
Grant Moore
committed
debugging oblige image
1 parent a261ed2 commit c4896be

File tree

7 files changed

+108
-28
lines changed

7 files changed

+108
-28
lines changed

Dockerfile.oblige

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ WORKDIR /build
2222
# Download, extract, and build Oblige 7.7.0
2323
RUN wget http://sourceforge.net/projects/oblige/files/Oblige/7.70/oblige-770-source.zip && \
2424
unzip oblige-770-source.zip && \
25-
mv oblige-770-source oblige
25+
mv Oblige-7.70-source oblige
2626

2727
WORKDIR /build/oblige
2828

@@ -35,8 +35,10 @@ FROM ubuntu:18.04
3535
ENV DEBIAN_FRONTEND=noninteractive
3636

3737
# Install only the runtime libraries required to execute the binary
38+
# Added libfltk-images1.3 to resolve the missing libfltk_images.so.1.3 dependency
3839
RUN apt-get update && apt-get install -y \
3940
libfltk1.3 \
41+
libfltk-images1.3 \
4042
zlib1g \
4143
libxft2 \
4244
libxinerama1 \
@@ -57,4 +59,4 @@ COPY --from=builder /build/oblige/language/ ./language/
5759
COPY --from=builder /build/oblige/data/ ./data/
5860

5961
# Default entrypoint routes to the executable
60-
ENTRYPOINT ["/opt/oblige/Oblige"]
62+
ENTRYPOINT ["./Oblige"]

app/sample/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11

22
from app.sample.randomize import randomize
33
from app.sample.generate import generate
4+
from app.sample.init import init
45

5-
__all__ = [ 'generate', 'randomize']
6+
__all__ = [ 'generate', 'randomize', 'init']

app/sample/init.py

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
"""
2+
Initialization Module: Environment Setup.
3+
"""
4+
# Standard Libraries
5+
import logging
6+
import subprocess
7+
import sys
8+
9+
# Application Libraries
10+
from app.models.config import GolemConfig
11+
from app.utils.conf import register_command
12+
13+
logger = logging.getLogger(__name__)
14+
15+
@register_command("init")
16+
def init(cfg: GolemConfig):
17+
"""
18+
Initializes the Golem environment by verifying and building required Docker images.
19+
"""
20+
logger.info("Initializing Golem environment...")
21+
image_name = "golem-oblige:latest"
22+
23+
# 1. Check if Docker is installed (executable exists in PATH)
24+
try:
25+
subprocess.run(
26+
["docker", "--version"],
27+
check=True,
28+
stdout=subprocess.DEVNULL,
29+
stderr=subprocess.DEVNULL
30+
)
31+
except FileNotFoundError:
32+
logger.error("Docker is not installed or not in PATH. Please install Docker to continue.")
33+
sys.exit(1)
34+
35+
# 2. Check if Docker daemon is running
36+
daemon_check = subprocess.run(
37+
["docker", "info"],
38+
stdout=subprocess.DEVNULL,
39+
stderr=subprocess.DEVNULL
40+
)
41+
if daemon_check.returncode != 0:
42+
logger.error("Docker daemon is not responsive. Please start Docker and try again.")
43+
sys.exit(1)
44+
45+
# 3. Check if the Oblige image already exists
46+
image_check = subprocess.run(
47+
["docker", "image", "inspect", image_name],
48+
stdout=subprocess.DEVNULL,
49+
stderr=subprocess.DEVNULL
50+
)
51+
52+
if image_check.returncode == 0:
53+
logger.info(f"Docker image '{image_name}' already exists. Ready for procedural generation.")
54+
return
55+
56+
# 4. Build the image
57+
logger.info(f"Docker image '{image_name}' not found. Initiating build...")
58+
build_cmd = [
59+
"docker", "buildx", "build",
60+
"-f", "Dockerfile.oblige",
61+
"-t", image_name,
62+
"--load", # Ensures the image is loaded into the local docker daemon
63+
"."
64+
]
65+
66+
try:
67+
# Note: We do not capture stdout/stderr here so the user can see
68+
# the standard Docker build progression in their terminal.
69+
subprocess.run(build_cmd, check=True)
70+
logger.info(f"Successfully built '{image_name}'.")
71+
except subprocess.CalledProcessError as e:
72+
logger.error(f"Failed to build '{image_name}'. Process exited with code: {e.returncode}")
73+
sys.exit(1)

app/utils/doom.py

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -22,25 +22,26 @@
2222

2323
class ObligeGenerator:
2424
def __init__(self, cfg: RandomizerConfig):
25-
self.executable = resolve_path(cfg.executable)
26-
self.output_dir = Path(resolve_path(cfg.output))
25+
# We ensure the output directory is an absolute path for Docker volume mounting
26+
self.output_dir = Path(resolve_path(cfg.output)).absolute()
2727
self.output_dir.mkdir(parents=True, exist_ok=True)
2828

2929
# Dump the Pydantic model into a dict so we can sample from it
3030
self.base_oblige_config = cfg.oblige.model_dump()
3131

32-
if not os.path.exists(self.executable):
33-
raise FileNotFoundError(f"Oblige executable not found at: {self.executable}")
34-
3532
def build_map(self, filename: str = "golem_procgen.wad") -> str:
36-
"""Compiles the map using the headless CLI with randomized parameters."""
33+
"""Compiles the map using the containerized Oblige engine with randomized parameters."""
3734
target_wad_absolute = str(self.output_dir / filename)
38-
temp_wad_name = "temp_batch.wad"
39-
40-
# HACK: There is an issue with how Oblige discovered the working directory of the executable
41-
# when it is called with an absolute path. This hack emulates the terminal exactly by
42-
# forcing argv[0] to be "./Oblige" instead of the absolute path.
43-
args = ["./Oblige", "--batch", temp_wad_name]
35+
temp_wad_name = "temp.wad"
36+
container_output_dir = "/output"
37+
38+
# Execute via Docker, mounting the host output directory to the container
39+
args = [
40+
"docker", "run", "--rm",
41+
"-v", f"{self.output_dir}:{container_output_dir}",
42+
"golem-oblige:latest",
43+
"--batch", f"{container_output_dir}/{temp_wad_name}"
44+
]
4445

4546
# Dynamically sample from lists to randomize the map config on the fly
4647
active_params = {}
@@ -49,24 +50,23 @@ def build_map(self, filename: str = "golem_procgen.wad") -> str:
4950
active_params[key] = chosen_val
5051
args.append(f"{key}={chosen_val}")
5152

52-
logger.info(f"Compiling procedural map with parameters: {active_params}")
53+
logger.info(f"Compiling procedural map via Docker with parameters: {active_params}")
5354

5455
try:
55-
oblige_dir = os.path.dirname(self.executable)
56-
subprocess.run(args, check=True, capture_output=True, text=True, cwd=oblige_dir)
56+
subprocess.run(args, check=True, capture_output=True, text=True)
5757

58-
compiled_temp_path = os.path.join(oblige_dir, temp_wad_name)
59-
if os.path.exists(compiled_temp_path):
60-
shutil.move(compiled_temp_path, target_wad_absolute)
58+
compiled_temp_path = self.output_dir / temp_wad_name
59+
if compiled_temp_path.exists():
60+
shutil.move(str(compiled_temp_path), target_wad_absolute)
6161
logger.info(f"Map compiled and moved successfully: {target_wad_absolute}")
6262
return target_wad_absolute
6363
else:
64-
raise FileNotFoundError("Oblige returned success, but the temporary WAD file is missing.")
64+
raise FileNotFoundError("Docker returned success, but the temporary WAD file is missing.")
6565

6666
except subprocess.CalledProcessError as e:
67-
logger.error(f"Oblige compilation failed with exit code {e.returncode}.")
68-
logger.error(f"Oblige STDOUT:\n{e.stdout}")
69-
logger.error(f"Oblige STDERR:\n{e.stderr}")
67+
logger.error(f"Oblige container failed with exit code {e.returncode}.")
68+
logger.error(f"Docker STDOUT:\n{e.stdout}")
69+
logger.error(f"Docker STDERR:\n{e.stderr}")
7070
raise
7171

7272

data/wads/temp.old

1.08 MB
Binary file not shown.

docs/model/training.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,10 @@ The data extraction, LNN optimization, and evaluation mechanics are orchestrated
166166

167167
### Data Inspection & Auditing
168168

169-
::: app.pipeline.analyze.inspect
169+
::: app.metrics.audit
170170

171-
::: app.pipeline.analyze.audit
171+
::: app.metrics.examine
172+
173+
::: app.metrics.inspect
174+
175+
::: app.metrics.summary

main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from app.client import remote, server, spectate, client
1212
from app.metrics import audit, examine, inspect, models, summary
1313
from app.pipeline import intervene, train, record, run
14-
from app.sample import generate, randomize
14+
from app.sample import generate, randomize, init
1515

1616
logger = logging.getLogger("main")
1717

0 commit comments

Comments
 (0)