def task_user_id_get(userId, type): # noqa: E501 """Returns all his own published or accepted tasks in the page. Returns the published tasks, the max number is 10. If the page is the last page, the return all left. # noqa: E501 :param userId: :type userId: str :param type: acceptment or publishment :type type: str :rtype: List[Task] """ tasks = task_manager.get_related_tasks(userId=userId, Type=type) if tasks is None: return ErrorResponse("error"), 400 else: return [ Task(id=item['task_id'], money=item['money'], icon=item['photo'], title=item['title'], max_num=item['max_num'], desc=item['task_intro'], part_num=item['participants_num']) for item in tasks ] return 'do some magic!'
def tasks_get(pageId, type=None): # noqa: E501 """Returns all related tasks according to the pageId. Returns the published tasks, the max number is 10. If the page is the last page, the return all left. # noqa: E501 :param pageId: Page number :type pageId: int :param type: default, recommend, easy :type type: str :rtype: List[Task] """ tasks = task_manager.get_task_list(page_id=pageId) if tasks is None: return ErrorResponse("error"), 400 else: return [ Task(id=item['task_id'], money=item['money'], icon=item['icon'], title=item['title'], max_num=item['max_num'], desc=item['task_intro'], part_num=item['participants_num']) for item in tasks ]
def test_add_task(self): """Test case for add_task Create a new Task """ body = Task() response = self.client.open('/motta/bampli/1.0.0-oas3/task/', method='POST', data=json.dumps(body), content_type='application/json') self.assert200(response, 'Response body is : ' + response.data.decode('utf-8'))
def test_add_task(self): """Test case for add_task add a new task to the todo list """ task = Task() response = self.client.open( '/aweiker/ToDo/1.0.0/list/{id}/tasks'.format(id='id_example'), method='POST', data=json.dumps(task), content_type='application/json') self.assert200(response, 'Response body is : ' + response.data.decode('utf-8'))
def add_task(body): # noqa: E501 """Create a new Task Adds a Task # noqa: E501 :param body: :type body: dict | bytes :rtype: Task """ if connexion.request.is_json: body = Task.from_dict(connexion.request.get_json()) # noqa: E501 return 'do some magic!'
def test_project_by_project_id_post(self): """Test case for project_by_project_id_post project_project_id_post """ body = Task() response = self.client.open( '//project/{project_id}'.format(project_id='project_id_example'), method='POST', data=json.dumps(body), content_type='application/json') self.assert200(response, 'Response body is : ' + response.data.decode('utf-8'))
def test_update_task(self): """Test case for update_task Update a Task """ body = Task() response = self.client.open( '/motta/bampli/1.0.0-oas3/task/{taskid}'.format( taskid='\"0e8c9fb0-ad98-11e6-bf2e-47644ada7c0f\"'), method='PUT', data=json.dumps(body), content_type='application/json') self.assert200(response, 'Response body is : ' + response.data.decode('utf-8'))
def update_task(body, taskid): # noqa: E501 """Update a Task Stores a Task # noqa: E501 :param body: :type body: dict | bytes :param taskid: Identifier of the Task :type taskid: str :rtype: Task """ if connexion.request.is_json: body = Task.from_dict(connexion.request.get_json()) # noqa: E501 return 'do some magic!'
def add_task(id, task=None): # noqa: E501 """add a new task to the todo list # noqa: E501 :param id: Unique identifier of the list to add the task for :type id: dict | bytes :param task: task to add :type task: dict | bytes :rtype: None """ if connexion.request.is_json: id = id.from_dict(connexion.request.get_json()) # noqa: E501 if connexion.request.is_json: task = Task.from_dict(connexion.request.get_json()) # noqa: E501 return 'do some magic!'
def tasks_get(pageId): # noqa: E501 """Returns all related tasks according to the pageId. Returns the published tasks, the max number is 10. If the page is the last page, the return all left. # noqa: E501 :param pageId: Page number :type pageId: int :rtype: List[Task] """ tasks = task_manager.get_task_list(page_id=pageId) if tasks is None: return ErrorResponse("error"), 400 else: return [ Task( id=item["task_id"], money=item["money"], icon=item["icon"], title=item["title"], max_num=item["max_num"], desc=item["task_intro"], part_num=item["participants_num"], ) for item in tasks ]
def step(task): # noqa: E501 """Single step of gradient descent Single step of gradient descent # noqa: E501 :param task: Sine Task Parameters :type task: dict | bytes :rtype: Predictions """ if connexion.request.is_json: task = Task.from_dict(connexion.request.get_json()) # noqa: E501 task = SineTask(task.amplitude, task.phase) x, y = task.next(_k) eval_x, eval_y = task.eval() losses = {} predictions = {} for model_name, model in _models.items(): model_loss, model_prediction = model.test(x=x, y=y, test_x=eval_x, test_y=eval_y, amplitude=task.amplitude) losses[model_name] = model_loss predictions[model_name] = model_prediction output = Predictions() output.datapoints = [] for i, _ in enumerate(x): datapoint = PredictionsDatapoints() datapoint.x = float(x[i]) datapoint.y = float(y[i]) output.datapoints.append(datapoint) output.evaluation = [] for i, _ in enumerate(eval_x): datapoint = PredictionsDatapoints() datapoint.x = float(eval_x[i]) datapoint.y = float(eval_y[i]) output.evaluation.append(datapoint) for model_name, loss in losses.items(): datapoints = [] for i, _ in enumerate(loss): datapoint = PredictionsDatapoints() datapoint.x = i datapoint.y = float(loss[i]) datapoints.append(datapoint) losses[model_name] = datapoints prediction_losses = PredictionsLosses() prediction_losses.baseline = losses["baseline"] prediction_losses.maml = losses["maml"] prediction_losses.fomaml = losses["fomamlv2"] prediction_losses.reptile0 = losses["reptile0"] prediction_losses.reptile9 = losses["reptile9"] output.losses = prediction_losses for model_name, prediction in predictions.items(): for i, step in enumerate(prediction): datapoints = [] for j, _ in enumerate(eval_x): datapoint = PredictionsDatapoints() datapoint.x = float(eval_x[j]) datapoint.y = float(step[j]) datapoints.append(datapoint) predictions[model_name][i] = datapoints predictions_predictions = PredictionsPredictions() predictions_predictions.baseline = predictions["baseline"] predictions_predictions.maml = predictions["maml"] predictions_predictions.fomaml = predictions["fomamlv2"] predictions_predictions.reptile0 = predictions["reptile0"] predictions_predictions.reptile9 = predictions["reptile9"] output.predictions = predictions_predictions return output