Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

configurable executable (path) for plotters #823

Merged
merged 6 commits into from
Jul 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 33 additions & 2 deletions src/plotman/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ def get_validated_configs(config_text: str, config_path: str, preset_target_defi

if loaded.plotting.type == "chia":
if loaded.plotting.chia is None:
# TODO: fix all the `TODO: use the configured executable` so this is not
# needed.
raise ConfigurationException(
"chia selected as plotter but plotting: chia: was not specified in the config",
)
Expand All @@ -81,6 +83,12 @@ def get_validated_configs(config_text: str, config_path: str, preset_target_defi
raise ConfigurationException(
"Chia Network plotter accepts up to one of plotting: pool_pk: and pool_contract_address: but both are specified",
)

executable_name = os.path.basename(loaded.plotting.chia.executable)
if executable_name != "chia":
raise ConfigurationException(
"plotting: chia: executable: must refer to an executable named chia"
)
elif loaded.plotting.type == "madmax":
if loaded.plotting.madmax is None:
raise ConfigurationException(
Expand All @@ -101,6 +109,14 @@ def get_validated_configs(config_text: str, config_path: str, preset_target_defi
"madMAx plotter accepts only one of plotting: pool_pk: and pool_contract_address: but both are specified",
)

executable_name = os.path.basename(loaded.plotting.madmax.executable)
if executable_name != "chia_plot":
# TODO: fix all the `TODO: use the configured executable` so this is not
# needed.
raise ConfigurationException(
"plotting: madmax: executable: must refer to an executable named chia_plot"
)

if loaded.archiving is not None:
preset_target_objects = yaml.safe_load(preset_target_definitions_text)
preset_target_schema = desert.schema(PresetTargetDefinitions)
Expand Down Expand Up @@ -312,6 +328,7 @@ class Scheduling:

@attr.frozen
class ChiaPlotterOptions:
executable: str = "chia"
n_threads: int = 2
n_buckets: int = 128
k: Optional[int] = 32
Expand All @@ -321,6 +338,7 @@ class ChiaPlotterOptions:

@attr.frozen
class MadmaxPlotterOptions:
executable: str = "chia_plot"
n_threads: int = 4
n_buckets: int = 256

Expand Down Expand Up @@ -369,9 +387,15 @@ class PlotmanConfig:
@contextlib.contextmanager
def setup(self) -> Generator[None, None, None]:
if self.plotting.type == 'chia':
if self.plotting.chia is None:
message = (
"internal plotman error, please report the full traceback and your"
+ " full configuration file"
)
raise Exception(message)
if self.plotting.pool_contract_address is not None:
completed_process = subprocess.run(
args=['chia', 'version'],
args=[self.plotting.chia.executable, 'version'],
capture_output=True,
check=True,
encoding='utf-8',
Expand All @@ -384,9 +408,16 @@ def setup(self) -> Generator[None, None, None]:
f' plots but found: {version}'
)
elif self.plotting.type == 'madmax':
if self.plotting.madmax is None:
message = (
"internal plotman error, please report the full traceback and your"
+ " full configuration file"
)
raise Exception(message)

if self.plotting.pool_contract_address is not None:
completed_process = subprocess.run(
args=['chia_plot', '--help'],
args=[self.plotting.madmax.executable, '--help'],
capture_output=True,
check=True,
encoding='utf-8',
Expand Down
5 changes: 5 additions & 0 deletions src/plotman/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,13 @@ def is_plotting_cmdline(cmdline: typing.List[str]) -> bool:
cmdline = cmdline[1:]
return (
len(cmdline) >= 3
# TODO: use the configured executable
and 'chia' in cmdline[0]
and 'plots' == cmdline[1]
and 'create' == cmdline[2]
)
elif cmdline and 'chia_plot' == os.path.basename(cmdline[0].lower()): # Madmax plotter
# TODO: use the configured executable
return True
return False

Expand All @@ -57,6 +59,7 @@ def parse_chia_plots_create_command_line(
if 'python' in command_line[0].lower(): # Stock Chia plotter
command_line = command_line[1:]
assert len(command_line) >= 3
# TODO: use the configured executable
assert 'chia' in command_line[0]
assert 'plots' == command_line[1]
assert 'create' == command_line[2]
Expand All @@ -66,6 +69,7 @@ def parse_chia_plots_create_command_line(
# copied.
command = chia.commands.latest_command()
elif 'chia_plot' in command_line[0].lower(): # Madmax plotter
# TODO: use the configured executable
command_line = command_line[1:]
all_command_arguments = command_line[2:]
command = madmax._cli_c8121b9
Expand Down Expand Up @@ -268,6 +272,7 @@ def __init__(
# 'nobitfield': False,
# 'exclude_final_dir': False,
# }
# TODO: use the configured executable
if proc.name().startswith("chia_plot"): # MADMAX
self.k = 32
self.r = self.args['threads'] # type: ignore[assignment]
Expand Down
5 changes: 3 additions & 2 deletions src/plotman/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ def key(key: str) -> job.Phase:
raise Exception(
"madmax plotter selected but not configured, report this as a plotman bug",
)
plot_args = ['chia_plot',
plot_args = [
plotting_cfg.madmax.executable,
'-n', str(1),
'-r', str(plotting_cfg.madmax.n_threads),
'-u', str(plotting_cfg.madmax.n_buckets),
Expand All @@ -158,7 +159,7 @@ def key(key: str) -> job.Phase:
raise Exception(
"chia plotter selected but not configured, report this as a plotman bug",
)
plot_args = ['chia', 'plots', 'create',
plot_args = [plotting_cfg.chia.executable, 'plots', 'create',
'-k', str(plotting_cfg.chia.k),
'-r', str(plotting_cfg.chia.n_threads),
'-u', str(plotting_cfg.chia.n_buckets),
Expand Down