def create_experiment( master_url: str, config: Dict[str, Any], model_context: context.Context, template: Optional[str] = None, validate_only: bool = False, archived: bool = False, activate: bool = True, additional_body_fields: Optional[Dict[str, Any]] = None, ) -> int: body = { "experiment_config": yaml.safe_dump(config), "model_definition": [e.dict() for e in model_context.entries], "validate_only": validate_only, } if template: body["template"] = template if archived: body["archived"] = archived if additional_body_fields: body.update(additional_body_fields) r = req.post(master_url, "experiments", body=body) if not hasattr(r, "headers"): raise Exception(r) if validate_only: return 0 new_resource = r.headers["Location"] experiment_id = int(new_resource.split("/")[-1]) if activate: activate_experiment(master_url, experiment_id) return experiment_id
def config(args: Namespace) -> None: result = api.get(args.master, "experiments/{}/config".format(args.experiment_id)) yaml.safe_dump(result.json(), stream=sys.stdout, default_flow_style=False)
def _parse_config(field: Any) -> Any: # Pretty print the config field. return yaml.safe_dump(yaml.safe_load(base64.b64decode(field)), default_flow_style=False)