call restful server to update experiment profile
342099
def update_experiment_profile(args, key, value):
    ''''''
    nni_config = Config(get_config_filename(args))
    rest_port = nni_config.get_config('restServerPort')
    running, _ = check_rest_server_quick(rest_port)
    if running:
        response = rest_get(experiment_url(rest_port), REST_TIME_OUT)
        if response and check_response(response):
            experiment_profile = json.loads(response.text)
            experiment_profile['params'][key] = value
            response = rest_put(experiment_url(rest_port)+get_query_type(key), json.dumps(experiment_profile), REST_TIME_OUT)
            if response and check_response(response):
                return response
    else:
        print_error('Restful server is not running...')
    return None
513631
def _update_request(self, data, options):
        
        data = json.dumps(data)

        if 'headers' not in options:
            options['headers'] = {}

        options['headers'].update({'Content-type': 'application/json'})

        return data, options
283471
def add_experiment(redis, name):
    """"""

    if not ALLOWED_NAMES.match(name):
        raise ExperimentException(name, "Illegal name")
    if redis.exists(EXPERIMENT_REDIS_KEY_TEMPLATE % name):
        raise ExperimentException(name, "Already exists")

    json = dict(creation_date=util.unicode_type(datetime.datetime.now()))
    pipe = redis.pipeline(transaction=True)
    pipe.sadd(ACTIVE_EXPERIMENTS_REDIS_KEY, name)
    pipe.hset(EXPERIMENT_REDIS_KEY_TEMPLATE % name, "metadata", escape.json_encode(json))
    pipe.execute()
    return Experiment(redis, name)
5598
def update
      url = single_url
      payload = attributes_to_payload
      payload[:reset_data] = true
      to_server url, payload
    end
682873
def reload(self):
        """"""

        app_profile_pb = self.instance_admin_client.get_app_profile(self.name)

        # NOTE: _update_from_pb does not check that the project and
        #       app_profile ID on the response match the request.
        self._update_from_pb(app_profile_pb)
1187102
def call(payload, apply_changes=False):
    '''
    
    '''
    session, cookies, csrf_token = logon()
    response = _post_request(session, payload, cookies, csrf_token)
    if apply_changes:
        apply_payload = {"jsonrpc": "2.0",
                         "id": "ID1",
                         "method": "apply_policy_changes",
                         "params": []}
        _post_request(session, apply_payload, cookies, csrf_token)
    logout(session, cookies, csrf_token)
    return response
118163
def reset_experiment(experiment):
    """"""
    redis = _get_redis_connection()
    experiment = Experiment.find(redis, experiment)
    if experiment:
        experiment.reset()
    return redirect(url_for('.index'))
230421
async def update(self) -> None:
        
        url = '{}{}'.format(self.url, ENDPOINT)

        try:
            async with self._session.get(url) as response:
                json_dict = demjson.decode(await response.text(), strict=False)
        except aiohttp.ClientError:
            json_dict = {'status': {'status1': SyncThru.OFFLINE}}
        except demjson.JSONDecodeError:
            raise ValueError("Invalid host, does not support SyncThru.")
        self.data = json_dict
373227
def refresh(self):
        """"""
        pipe = self.redis.pipeline()
        pipe.hget(EXPERIMENT_REDIS_KEY_TEMPLATE % self.name, "metadata")
        pipe.hget(EXPERIMENT_REDIS_KEY_TEMPLATE % self.name, "choices")
        pipe.hget(EXPERIMENT_REDIS_KEY_TEMPLATE % self.name, "default-choice")
        results = pipe.execute()

        if results[0] == None:
            raise ExperimentException(self.name, "Does not exist")

        self.metadata = parse_json(results[0])
        self.choice_names = parse_json(results[1]) if results[1] != None else []
        self.default_choice = escape.to_unicode(results[2])
        self._choices = None
273134
function (req, res, next) {
    var accessToken = req.accessToken;
    var headers = { 'User-Agent': 'Satellizer' };
    var userApiUrl = 'https://api.github.com/user';

    request.get({ url: userApiUrl, qs: accessToken, headers: headers, json: true }, function(err, response, profile) {
      if (err) {
        res.status(500).send(err);
        return;
      }
      req.profile = profile;
      next();
    });
  }
872865
def update(self,
               stats,
               duration=3,
               cs_status=None,
               return_to_browser=False):
        
        # Flush display
        logger.debug('Servers list: {}'.format(stats))
        self.flush(stats)

        # Wait
        exitkey = False
        countdown = Timer(self.__refresh_time)
        while not countdown.finished() and not exitkey:
            # Getkey
            pressedkey = self.__catch_key(stats)
            # Is it an exit or select server key ?
            exitkey = (
                pressedkey == ord('\x1b') or pressedkey == ord('q') or pressedkey == 10)
            if not exitkey and pressedkey > -1:
                # Redraw display
                self.flush(stats)
            # Wait 100ms...
            self.wait()

        return self.active_server
796670
def update_org_smarthost(self, orgid, serverid, data):
        """"""
        return self.api_call(
            ENDPOINTS['orgsmarthosts']['update'],
            dict(orgid=orgid, serverid=serverid),
            body=data)
517066
def update(self, request, pk=None, parent_lookup_organization=None):
        ''''''
        user = get_object_or_404(User, pk=pk)
        org = get_object_or_404(
            SeedOrganization, pk=parent_lookup_organization)
        self.check_object_permissions(request, org)
        org.users.add(user)
        return Response(status=status.HTTP_204_NO_CONTENT)
636118
def set_alternative_view(self, request):
        
        if not request.user.has_perm('experiments.change_experiment'):
            return HttpResponseForbidden()

        experiment_name = request.POST.get("experiment")
        alternative_name = request.POST.get("alternative")
        if not (experiment_name and alternative_name):
            return HttpResponseBadRequest()

        participant(request).set_alternative(experiment_name, alternative_name)
        return JsonResponse({
            'success': True,
            'alternative': participant(request).get_alternative(experiment_name)
        })
254533
def update_db(self, giver, receiverkarma):
        

        for receiver in receiverkarma:
            if receiver != giver:
                urow = KarmaStatsTable(
                    ude(giver), ude(receiver), receiverkarma[receiver])
                self.db.session.add(urow)
        self.db.session.commit()
1344228
def update_project(project, opts = {})
      data, _status_code, _headers = update_project_with_http_info(project, opts)
      return data
    end
616778
def start_rest_server(port, platform, mode, config_file_name, experiment_id=None, log_dir=None, log_level=None):
    ''''''
    nni_config = Config(config_file_name)
    if detect_port(port):
        print_error('Port %s is used by another process, please reset the port!\n' \
        'You could use \'nnictl create --help\' to get help information' % port)
        exit(1)
    
    if (platform != 'local') and detect_port(int(port) + 1):
        print_error('PAI mode need an additional adjacent port %d, and the port %d is used by another process!\n' \
        'You could set another port to start experiment!\n' \
        'You could use \'nnictl create --help\' to get help information' % ((int(port) + 1), (int(port) + 1)))
        exit(1)

    print_normal('Starting restful server...')
    
    entry_dir = get_nni_installation_path()
    entry_file = os.path.join(entry_dir, 'main.js')
    
    node_command = 'node'
    if sys.platform == 'win32':
        node_command = os.path.join(entry_dir[:-3], 'Scripts', 'node.exe')
    cmds = [node_command, entry_file, '--port', str(port), '--mode', platform, '--start_mode', mode]
    if log_dir is not None:
        cmds += ['--log_dir', log_dir]
    if log_level is not None:
        cmds += ['--log_level', log_level]
    if mode == 'resume':
        cmds += ['--experiment_id', experiment_id]
    stdout_full_path, stderr_full_path = get_log_path(config_file_name)
    stdout_file = open(stdout_full_path, 'a+')
    stderr_file = open(stderr_full_path, 'a+')
    time_now = time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(time.time()))
    #add time information in the header of log files
    log_header = LOG_HEADER % str(time_now)
    stdout_file.write(log_header)
    stderr_file.write(log_header)
    if sys.platform == 'win32':
        from subprocess import CREATE_NEW_PROCESS_GROUP
        process = Popen(cmds, cwd=entry_dir, stdout=stdout_file, stderr=stderr_file, creationflags=CREATE_NEW_PROCESS_GROUP)
    else:
        process = Popen(cmds, cwd=entry_dir, stdout=stdout_file, stderr=stderr_file)
    return process, str(time_now)