Generate: Add `--skip_output` flag to bypass assertion and output stages. (#2416)
This commit is contained in:
parent
9312ad9bfe
commit
5d9896773d
|
@ -20,7 +20,7 @@ import Options
|
||||||
from BaseClasses import seeddigits, get_seed, PlandoOptions
|
from BaseClasses import seeddigits, get_seed, PlandoOptions
|
||||||
from Main import main as ERmain
|
from Main import main as ERmain
|
||||||
from settings import get_settings
|
from settings import get_settings
|
||||||
from Utils import parse_yamls, version_tuple, __version__, tuplize_version, user_path
|
from Utils import parse_yamls, version_tuple, __version__, tuplize_version
|
||||||
from worlds.alttp import Options as LttPOptions
|
from worlds.alttp import Options as LttPOptions
|
||||||
from worlds.alttp.EntranceRandomizer import parse_arguments
|
from worlds.alttp.EntranceRandomizer import parse_arguments
|
||||||
from worlds.alttp.Text import TextTable
|
from worlds.alttp.Text import TextTable
|
||||||
|
@ -53,6 +53,9 @@ def mystery_argparse():
|
||||||
help='List of options that can be set manually. Can be combined, for example "bosses, items"')
|
help='List of options that can be set manually. Can be combined, for example "bosses, items"')
|
||||||
parser.add_argument("--skip_prog_balancing", action="store_true",
|
parser.add_argument("--skip_prog_balancing", action="store_true",
|
||||||
help="Skip progression balancing step during generation.")
|
help="Skip progression balancing step during generation.")
|
||||||
|
parser.add_argument("--skip_output", action="store_true",
|
||||||
|
help="Skips generation assertion and output stages and skips multidata and spoiler output. "
|
||||||
|
"Intended for debugging and testing purposes.")
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
if not os.path.isabs(args.weights_file_path):
|
if not os.path.isabs(args.weights_file_path):
|
||||||
args.weights_file_path = os.path.join(args.player_files_path, args.weights_file_path)
|
args.weights_file_path = os.path.join(args.player_files_path, args.weights_file_path)
|
||||||
|
@ -150,6 +153,7 @@ def main(args=None, callback=ERmain):
|
||||||
erargs.outputname = seed_name
|
erargs.outputname = seed_name
|
||||||
erargs.outputpath = args.outputpath
|
erargs.outputpath = args.outputpath
|
||||||
erargs.skip_prog_balancing = args.skip_prog_balancing
|
erargs.skip_prog_balancing = args.skip_prog_balancing
|
||||||
|
erargs.skip_output = args.skip_output
|
||||||
|
|
||||||
settings_cache: Dict[str, Tuple[argparse.Namespace, ...]] = \
|
settings_cache: Dict[str, Tuple[argparse.Namespace, ...]] = \
|
||||||
{fname: (tuple(roll_settings(yaml, args.plando) for yaml in yamls) if args.samesettings else None)
|
{fname: (tuple(roll_settings(yaml, args.plando) for yaml in yamls) if args.samesettings else None)
|
||||||
|
|
13
Main.py
13
Main.py
|
@ -13,8 +13,8 @@ import worlds
|
||||||
from BaseClasses import CollectionState, Item, Location, LocationProgressType, MultiWorld, Region
|
from BaseClasses import CollectionState, Item, Location, LocationProgressType, MultiWorld, Region
|
||||||
from Fill import balance_multiworld_progression, distribute_items_restrictive, distribute_planned, flood_items
|
from Fill import balance_multiworld_progression, distribute_items_restrictive, distribute_planned, flood_items
|
||||||
from Options import StartInventoryPool
|
from Options import StartInventoryPool
|
||||||
from settings import get_settings
|
|
||||||
from Utils import __version__, output_path, version_tuple
|
from Utils import __version__, output_path, version_tuple
|
||||||
|
from settings import get_settings
|
||||||
from worlds import AutoWorld
|
from worlds import AutoWorld
|
||||||
from worlds.generic.Rules import exclusion_rules, locality_rules
|
from worlds.generic.Rules import exclusion_rules, locality_rules
|
||||||
|
|
||||||
|
@ -101,7 +101,9 @@ def main(args, seed=None, baked_server_options: Optional[Dict[str, object]] = No
|
||||||
|
|
||||||
del item_digits, location_digits, item_count, location_count
|
del item_digits, location_digits, item_count, location_count
|
||||||
|
|
||||||
AutoWorld.call_stage(world, "assert_generate")
|
# This assertion method should not be necessary to run if we are not outputting any multidata.
|
||||||
|
if not args.skip_output:
|
||||||
|
AutoWorld.call_stage(world, "assert_generate")
|
||||||
|
|
||||||
AutoWorld.call_all(world, "generate_early")
|
AutoWorld.call_all(world, "generate_early")
|
||||||
|
|
||||||
|
@ -287,11 +289,14 @@ def main(args, seed=None, baked_server_options: Optional[Dict[str, object]] = No
|
||||||
else:
|
else:
|
||||||
logger.info("Progression balancing skipped.")
|
logger.info("Progression balancing skipped.")
|
||||||
|
|
||||||
logger.info(f'Beginning output...')
|
|
||||||
|
|
||||||
# we're about to output using multithreading, so we're removing the global random state to prevent accidental use
|
# we're about to output using multithreading, so we're removing the global random state to prevent accidental use
|
||||||
world.random.passthrough = False
|
world.random.passthrough = False
|
||||||
|
|
||||||
|
if args.skip_output:
|
||||||
|
logger.info('Done. Skipped output/spoiler generation. Total Time: %s', time.perf_counter() - start)
|
||||||
|
return world
|
||||||
|
|
||||||
|
logger.info(f'Beginning output...')
|
||||||
outfilebase = 'AP_' + world.seed_name
|
outfilebase = 'AP_' + world.seed_name
|
||||||
|
|
||||||
output = tempfile.TemporaryDirectory()
|
output = tempfile.TemporaryDirectory()
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
|
import concurrent.futures
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import pickle
|
import pickle
|
||||||
import random
|
import random
|
||||||
import tempfile
|
import tempfile
|
||||||
import zipfile
|
import zipfile
|
||||||
import concurrent.futures
|
|
||||||
from collections import Counter
|
from collections import Counter
|
||||||
from typing import Dict, Optional, Any, Union, List
|
from typing import Any, Dict, List, Optional, Union
|
||||||
|
|
||||||
from flask import request, flash, redirect, url_for, session, render_template
|
from flask import flash, redirect, render_template, request, session, url_for
|
||||||
from pony.orm import commit, db_session
|
from pony.orm import commit, db_session
|
||||||
|
|
||||||
from BaseClasses import seeddigits, get_seed
|
from BaseClasses import get_seed, seeddigits
|
||||||
from Generate import handle_name, PlandoOptions
|
from Generate import PlandoOptions, handle_name
|
||||||
from Main import main as ERmain
|
from Main import main as ERmain
|
||||||
from Utils import __version__
|
from Utils import __version__
|
||||||
from WebHostLib import app
|
from WebHostLib import app
|
||||||
|
@ -131,6 +131,7 @@ def gen_game(gen_options: dict, meta: Optional[Dict[str, Any]] = None, owner=Non
|
||||||
erargs.plando_options = PlandoOptions.from_set(meta.setdefault("plando_options",
|
erargs.plando_options = PlandoOptions.from_set(meta.setdefault("plando_options",
|
||||||
{"bosses", "items", "connections", "texts"}))
|
{"bosses", "items", "connections", "texts"}))
|
||||||
erargs.skip_prog_balancing = False
|
erargs.skip_prog_balancing = False
|
||||||
|
erargs.skip_output = False
|
||||||
|
|
||||||
name_counter = Counter()
|
name_counter = Counter()
|
||||||
for player, (playerfile, settings) in enumerate(gen_options.items(), 1):
|
for player, (playerfile, settings) in enumerate(gen_options.items(), 1):
|
||||||
|
|
Loading…
Reference in New Issue