def __init__(self, problem_id, time_limit, memory_limit, meta): self.id = problem_id self.time_limit = time_limit self.memory_limit = memory_limit self.meta = ConfigNode(meta) self.generator_manager = GeneratorManager() # Cache root dir so that we don't need to scan all roots (potentially very slow on networked mount). self.root_dir = get_problem_root(problem_id) self.problem_data = ProblemDataManager(self) # Checkers modules must be stored in a dict, for the duration of execution, # lest globals be deleted with the module. self._checkers = {} try: doc = yaml.safe_load(self.problem_data['init.yml']) if not doc: raise InvalidInitException( 'I find your lack of content disturbing.') self.config = ConfigNode(doc, defaults={ 'wall_time_factor': 3, 'output_prefix_length': 64, 'output_limit_length': 25165824, 'binary_data': False, 'short_circuit': True, 'symlinks': {}, 'meta': meta, }) except (IOError, KeyError, ParserError, ScannerError) as e: raise InvalidInitException(str(e)) self.problem_data.archive = self._resolve_archive_files() self._resolve_test_cases()
def __init__(self, problem_id, time_limit, memory_limit, load_pretests_only=False): self.id = problem_id self.time_limit = time_limit self.memory_limit = memory_limit self.generator_manager = GeneratorManager() self.problem_data = ProblemDataManager(problem_id) # Checkers modules must be stored in a dict, for the duration of execution, # lest globals be deleted with the module. self._checkers = {} self._testcase_counter = 0 self._batch_counter = 0 try: doc = yaml.safe_load(self.problem_data['init.yml']) if not doc: raise InvalidInitException('I find your lack of content disturbing.') self.config = ConfigNode(doc, defaults={ 'wall_time_factor': 3, 'output_prefix_length': 64, 'output_limit_length': 25165824, 'binary_data': False, 'short_circuit': True, }) except (IOError, ParserError, ScannerError) as e: raise InvalidInitException(str(e)) self.problem_data.archive = self._resolve_archive_files() self.is_pretested = load_pretests_only and 'pretest_test_cases' in self.config self.cases = self._resolve_testcases(self.config['pretest_test_cases' if self.is_pretested else 'test_cases'])
def __init__(self, judge, problem, language, source, meta): self.source = utf8bytes(source) self.language = language self.problem = problem self.judge = judge self.meta = ConfigNode(meta) self.binary = self._generate_binary() self.is_pretested = self.meta.pretests_only and 'pretest_test_cases' in self.problem.config self._terminate_grading = False self._current_proc = None self._batch_counter = 0 self._testcase_counter = 0
def setUp(self): self.c = ConfigNode( defaults={ 'bool': True, 'int': 1, 'list': [0, 1, 2], 'str': 'foo', 'dict': { 'foo': 'bar', }, 'dynamic1+': '5 * 2', 'dynamic2++': 'node = {"foo": 1, "bar+": "list(range(2))"}', })
def __init__(self, problem_id, time_limit, memory_limit, meta): self.id = problem_id self.time_limit = time_limit self.memory_limit = memory_limit self.meta = ConfigNode(meta) # Cache root dir so that we don't need to scan all roots (potentially very slow on networked mount). self.root_dir = get_problem_root(problem_id) self.problem_data = ProblemDataManager(self.root_dir) # Checkers modules must be stored in a dict, for the duration of execution, # lest globals be deleted with the module. self._checkers = {} self.config = ProblemConfig(self.problem_data, meta) self.problem_data.archive = self._resolve_archive_files() self._resolve_test_cases()
class InvocationCase(object): config = ConfigNode({'unbuffered': False}) io_redirects = lambda: None input_data = lambda: input_data
import six import yaml from dmoj.config import ConfigNode from dmoj.utils.unicode import utf8text try: import ssl except ImportError: ssl = None problem_dirs = () problem_watches = () env = ConfigNode(defaults={ 'selftest_sandboxing': True, 'runtime': {}, }, dynamic=False) _root = os.path.dirname(__file__) log_file = server_host = server_port = no_ansi = no_ansi_emu = no_watchdog = problem_regex = case_regex = None secure = no_cert_check = False cert_store = api_listen = None startup_warnings = [] only_executors = set() exclude_executors = set() def load_env(cli=False, testsuite=False): # pragma: no cover
env = ConfigNode( defaults={ 'selftest_sandboxing': True, 'selftest_time_limit': 10, # 10 seconds 'selftest_memory_limit': 65536, # 64mb of RAM 'generator_sandboxing': True, 'generator_time_limit': 20, # 20 seconds 'generator_memory_limit': 524288, # 512mb of RAM 'compiler_time_limit': 10, # Kill compiler after 10 seconds 'compiler_size_limit': 131072, # Maximum allowable compiled file size, 128mb 'compiler_output_character_limit': 65536, # Number of characters allowed in compile output 'runtime': {}, # Map of executor: [list of extra allowed file regexes], used to configure # the filesystem sandbox on a per-machine basis, without having to hack # executor source. 'extra_fs': {}, # List of judge URLs to ping on problem data updates (the URLs are expected # to host judges running with --api-host and --api-port) 'update_pings': [], # Directory to use as temporary submission storage, system default # (e.g. /tmp) if left blank. MANDATORY on Windows. 'tempdir': None, # Windows-only settings 'inject32': None, # Path to wbox's dmsec32.dll 'inject64': None, # Path to wbox's dmsec64.dll 'inject_func': None, # Name of injected DLL's entry point (e.g. InjectMain) }, dynamic=False)
problem_watches = () env = ConfigNode( defaults={ 'selftest_time_limit': 10, # 10 seconds 'selftest_memory_limit': 131072, # 128mb of RAM 'generator_compiler_time_limit': 30, # 30 seconds 'generator_time_limit': 20, # 20 seconds 'generator_memory_limit': 524288, # 512mb of RAM 'compiler_time_limit': 10, # Kill compiler after 10 seconds 'compiler_size_limit': 131072, # Maximum allowable compiled file size, 128mb 'compiler_output_character_limit': 65536, # Number of characters allowed in compile output 'compiled_binary_cache_dir': None, # Location to store cached binaries, defaults to tempdir 'compiled_binary_cache_size': 100, # Maximum number of executables to cache (LRU order) 'runtime': {}, # Map of executor: [list of extra allowed file regexes], used to configure # the filesystem sandbox on a per-machine basis, without having to hack # executor source. 'extra_fs': {}, # List of judge URLs to ping on problem data updates (the URLs are expected # to host judges running with --api-host and --api-port) 'update_pings': [], # Directory to use as temporary submission storage, system default # (e.g. /tmp) if left blank. 'tempdir': None, }, dynamic=False, ) _root = os.path.dirname(__file__)
env = ConfigNode( defaults={ 'selftest_time_limit': 10, # 10 seconds 'selftest_memory_limit': 131072, # 128mb of RAM 'generator_compiler_time_limit': 30, # 30 seconds 'generator_time_limit': 20, # 20 seconds 'generator_memory_limit': 524288, # 512mb of RAM 'compiler_time_limit': 10, # Kill compiler after 10 seconds 'compiler_size_limit': 131072, # Maximum allowable compiled file size, 128mb 'compiler_output_character_limit': 65536, # Number of characters allowed in compile output 'compiled_binary_cache_dir': None, # Location to store cached binaries, defaults to tempdir 'compiled_binary_cache_size': 100, # Maximum number of executables to cache (LRU order) 'runtime': {}, # Map of executor: fs_config, used to configure # the filesystem sandbox on a per-machine basis, without having to hack # executor source. # fs_config is a list of dictionaries. Each dictionary should contain one key/value pair. # Three keys are possible: # `exact_file`, to allow a specific file # `exact_dir`, to allow listing files in a directory # `recursive_dir`, to allow everything under and including a directory # Example YAML: # extra_fs: # PERL: # - exact_file: /dev/dtrace/helper # - exact_dir: /some/exact/directory # - recursive_dir: /some/directory/and/all/children 'extra_fs': {}, # List of judge URLs to ping on problem data updates (the URLs are expected # to host judges running with --api-host and --api-port) 'update_pings': [], # Directory to use as temporary submission storage, system default # (e.g. /tmp) if left blank. 'tempdir': None, # CPU affinity (as a list of 0-indexed CPU IDs) to run submissions on 'submission_cpu_affinity': None, }, dynamic=False, )