def update_problem_class(Class, problem_object, seed, user, instance_directory):
"""
Changes the metaclass of the given class to introduce necessary fields before
object instantiation.
Args:
Class: The problem class to be updated
problem_name: The problem name
seed: The seed for the Random object
user: The linux username for this challenge instance
instance_directory: The deployment directory for this instance
Returns:
The updated class described above
"""
random = Random(seed)
attributes = deepcopy(problem_object)
# pass configuration options in as class fields
attributes.update(dict(deploy_config))
attributes.update({"random": random, "user": user, "directory": instance_directory,
"server": deploy_config.hostname})
return challenge_meta(attributes)(Class.__name__, Class.__bases__, Class.__dict__)
评论列表
文章目录