def delete_request(context, url_path_segment): url = append_path(context.server, url_path_segment) context.response = requests.delete( url, headers=context.headers, auth=context.auth )
def read_action(action_path): action_name=get_action_name(action_path) category=get_category(action_name) person=get_person(action_name) all_files=utils.get_files(action_path) all_files=utils.append_path(action_path+"/",all_files) frames=utils.read_images(all_files) return Action(category,person,frames)
def get_actions(action_dir,nn_path,cls_path): action_files=utils.get_all_dirs(action_dir) action_files=utils.append_path(action_dir,action_files) reduction=AutoEncoderReduction(nn_path) cls=Clusters(cls_path) def curried(action_path): return get_deep_frames(action_path,reduction,cls) return map(curried,action_files)
def get_image_with_bbox(attrs): images = parse_file(config.get('deepfashion', 'attributes_file'), val_type=int, key_item_id=None, validate_fields=False) attrs = parse_attr(attrs, _PREDEFINED_ATTR) filtered = filter_items(images, attrs) image_files = append_path(config.get('deepfashion', 'image_dir'), filtered, key='image_name') boxes = bbox(filtered) return image_files, boxes
def step_impl(context, timeinseconds): # This can be used if no WAIT-blocking is available jobId = context.job.get_jobId() url = append_path(context.server, jobId + "/phase") phase = None status_code = 200 final_phases = ["ABORTED", "COMPLETED", "ERROR", "ARCHIVED"] while phase not in final_phases and status_code == 200: time.sleep(int(timeinseconds)) response = requests.get(url, headers=context.headers, auth=context.auth) phase = response.text status_code = response.status_code if status_code != 200: raise NotImplementedError("Got status_code %d while waiting for final state." % (status_code)) # make one final request to get all the job details url = append_path(context.server, jobId) context.response = requests.get(url, headers=context.headers, auth=context.auth)
def step_impl(context, timeinseconds): # This can be used if no WAIT-blocking is available jobId = context.job.get_jobId() url = append_path(context.server, jobId + "/phase") phase = "PENDING" status_code = 200 pre_starting_phase = ["PENDING", "QUEUED", "HELD", "SUSPENDED"] while phase in pre_starting_phase and status_code == 200: time.sleep(int(timeinseconds)) response = requests.get(url, headers=context.headers, auth=context.auth) phase = response.text status_code = response.status_code if status_code != 200: raise NotImplementedError("Got status_code %d while waiting for job execution." % (status_code)) # make one final request to get all the job details url = append_path(context.server, jobId) context.response = requests.get(url, headers=context.headers, auth=context.auth)
def step_impl(context, url_path_segment): url = append_path(context.server, url_path_segment) print(" GET request to: ", url) if context.auth != (u'', u''): print(" with authentication details: ", context.auth) # if not url_path_segment.startswith('?'): # raise NotImplementedError("url: %r" % url) context.response = requests.get( url, headers=context.headers, auth=context.auth )
async def get_sensitive_urls(self, paths, valid_status_codes=None): session = self.get_http_session() results = {} async with trio.open_nursery() as nursery: for path, description in paths.items(): for domain, _ in self.iter_domains(): nursery.start_soon( self.probe_url, session, utils.append_path(f"http://{domain}", path), description, valid_status_codes[domain] if valid_status_codes else None, results) return results
def load_data(path,batch_size=25): all_files=utils.get_all_files(path) all_files=utils.append_path(path,all_files) images=utils.read_images(all_files) images=utils.flatten_images(images) images=map(utils.normalize,images) images=np.array(images) n_batches=get_number_of_batches(batch_size,len(images)) def get_batch(i): return images[i * batch_size: (i+1) * batch_size] batches=map(get_batch,range(n_batches)) batches = [np.array(batch) for batch in batches] print("Dataset loaded") return np.array(batches)
def step_impl(context, url_path_segment): # convert given table-data to dictionary datadict = get_dict_from_paramtable(context.table) url = append_path(context.server, url_path_segment) print(" POST request to URL: ", url) if context.auth != (u'', u''): print(" with authentication details: ", context.auth) context.response = requests.post( url, data=datadict, headers=context.headers, auth=context.auth )
def read_action_frame(dir_path): actions_paths=utils.get_dirs(dir_path) actions_paths=utils.append_path(dir_path, actions_paths) actions=[read_action(path) for path in actions_paths] return create_action_frame(actions)
def get_image_files(attrs): images = parse_file(config.get('celeba', 'attributes_file')) attrs = parse_attr(attrs, _PREDEFINED_ATTR) filtered = filter_items(images, attrs) return append_path(config.get('celeba', 'image_dir'), filtered)
def get_actions(action_dir,cls): action_files=utils.get_dirs(action_dir) action_files=utils.append_path(action_dir,action_files) return [compute_sequence(path,cls) for path in action_files]