Search is not available for this dataset
text
stringlengths
75
104k
def url(self, suffix=""): """ Return a constructed URL, appending an optional suffix (uri path). Arguments: suffix (str : ""): The suffix to append to the end of the URL Returns: str: The complete URL """ return super(neuroRemote, ...
def reserve_ids(self, token, channel, quantity): """ Requests a list of next-available-IDs from the server. Arguments: quantity (int): The number of IDs to reserve Returns: int[quantity]: List of IDs you've been granted """ quantity = str(quantit...
def merge_ids(self, token, channel, ids, delete=False): """ Call the restful endpoint to merge two RAMON objects into one. Arguments: token (str): The token to inspect channel (str): The channel to inspect ids (int[]): the list of the IDs to merge ...
def create_channels(self, dataset, token, new_channels_data): """ Creates channels given a dictionary in 'new_channels_data' , 'dataset' name, and 'token' (project) name. Arguments: token (str): Token to identify project dataset (str): Dataset name to identify da...
def propagate(self, token, channel): """ Kick off the propagate function on the remote server. Arguments: token (str): The token to propagate channel (str): The channel to propagate Returns: boolean: Success """ if self.get_propagate_...
def get_propagate_status(self, token, channel): """ Get the propagate status for a token/channel pair. Arguments: token (str): The token to check channel (str): The channel to check Returns: str: The status code """ url = self.url('sd...
def create_project(self, project_name, dataset_name, hostname, is_public, s3backend=0, kvserver='localhost', kvengine='MySQL', mdengine=...
def list_projects(self, dataset_name): """ Lists a set of projects related to a dataset. Arguments: dataset_name (str): Dataset name to search projects for Returns: dict: Projects found based on dataset query """ url = self.url() + "/nd/resource/...
def create_token(self, token_name, project_name, dataset_name, is_public): """ Creates a token with the given parameters. Arguments: project_name (str): Project name dataset_name (str): Da...
def get_token(self, token_name, project_name, dataset_name): """ Get a token with the given parameters. Arguments: project_name (str): Project name dataset_name (str): Dataset name project is based on token...
def delete_token(self, token_name, project_name, dataset_name): """ Delete a token with the given parameters. Arguments: project_name (str): Project name dataset_name (str): Dataset name project is based on ...
def list_tokens(self): """ Lists a set of tokens that are public in Neurodata. Arguments: Returns: dict: Public tokens found in Neurodata """ url = self.url() + "/nd/resource/public/token/" req = self.remote_utils.get_url(url) if req.status_co...
def create_dataset(self, name, x_img_size, y_img_size, z_img_size, x_vox_res, y_vox_res, z_vox_res, x_offset=0, y...
def get_dataset(self, name): """ Returns info regarding a particular dataset. Arugments: name (str): Dataset name Returns: dict: Dataset information """ url = self.url() + "/resource/dataset/{}".format(name) req = self.remote_utils.get_ur...
def list_datasets(self, get_global_public): """ Lists datasets in resources. Setting 'get_global_public' to 'True' will retrieve all public datasets in cloud. 'False' will get user's public datasets. Arguments: get_global_public (bool): True if user wants all public ...
def delete_dataset(self, name): """ Arguments: name (str): Name of dataset to delete Returns: bool: True if dataset deleted, False if not """ url = self.url() + "/resource/dataset/{}".format(name) req = self.remote_utils.delete_url(url) i...
def create_channel(self, channel_name, project_name, dataset_name, channel_type, dtype, startwindow, endwindow, readonly=0, ...
def get_channel(self, channel_name, project_name, dataset_name): """ Gets info about a channel given its name, name of its project , and name of its dataset. Arguments: channel_name (str): Channel name project_name (str): Project name dataset_name (st...
def parse(self): """Parse show subcommand.""" parser = self.subparser.add_parser( "show", help="Show workspace details", description="Show workspace details.") group = parser.add_mutually_exclusive_group(required=True) group.add_argument('--all', acti...
def execute(self, args): """Execute show subcommand.""" if args.name is not None: self.show_workspace(slashes2dash(args.name)) elif args.all is not None: self.show_all()
def show_workspace(self, name): """Show specific workspace.""" if not self.workspace.exists(name): raise ValueError("Workspace `%s` doesn't exists." % name) color = Color() workspaces = self.workspace.list() self.logger.info("<== %s workspace ==>" % color.colored(na...
def show_all(self): """Show details for all workspaces.""" for ws in self.workspace.list().keys(): self.show_workspace(ws) print("\n\n")
def url(self, endpoint=''): """ Get the base URL of the Remote. Arguments: None Returns: `str` base URL """ if not endpoint.startswith('/'): endpoint = "/" + endpoint return self.protocol + "://" + self.hostname + endpoint
def ping(self, endpoint=''): """ Ping the server to make sure that you can access the base URL. Arguments: None Returns: `boolean` Successful access of server (or status code) """ r = requests.get(self.url() + "/" + endpoint) return r.stat...
def export_dae(filename, cutout, level=0): """ Converts a dense annotation to a DAE, using Marching Cubes (PyMCubes). Arguments: filename (str): The filename to write out to cutout (numpy.ndarray): The dense annotation level (int): The level at which to run mcubes Returns: ...
def export_obj(filename, cutout, level=0): """ Converts a dense annotation to a obj, using Marching Cubes (PyMCubes). Arguments: filename (str): The filename to write out to cutout (numpy.ndarray): The dense annotation level (int): The level at which to run mcubes Returns: ...
def export_ply(filename, cutout, level=0): """ Converts a dense annotation to a .PLY, using Marching Cubes (PyMCubes). Arguments: filename (str): The filename to write out to cutout (numpy.ndarray): The dense annotation level (int): The level at which to run mcubes Returns: ...
def _guess_format_from_extension(ext): """ Guess the appropriate data type from file extension. Arguments: ext: The file extension (period optional) Returns: String. The format (without leading period), or False if none was found or couldn't be guessed """ ...
def open(in_file, in_fmt=None): """ Reads in a file from disk. Arguments: in_file: The name of the file to read in in_fmt: The format of in_file, if you want to be explicit Returns: numpy.ndarray """ fmt = in_file.split('.')[-1] if in_fmt: fmt = in_fmt f...
def convert(in_file, out_file, in_fmt="", out_fmt=""): """ Converts in_file to out_file, guessing datatype in the absence of in_fmt and out_fmt. Arguments: in_file: The name of the (existing) datafile to read out_file: The name of the file to create with converted data in_f...
def build_graph(self, project, site, subject, session, scan, size, email=None, invariants=Invariants.ALL, fiber_file=DEFAULT_FIBER_FILE, atlas_file=None, use_threads=False, callback=None): """ Builds a graph using the graph-services endpoint. ...
def compute_invariants(self, graph_file, input_format, invariants=Invariants.ALL, email=None, use_threads=False, callback=None): """ Compute invariants from an existing GraphML file using the remote grute graph services. Arguments: ...
def convert_graph(self, graph_file, input_format, output_formats, email=None, use_threads=False, callback=None): """ Convert a graph from one GraphFormat to another. Arguments: graph_file (str): Filename of the file to convert input_format (str): A ...
def to_dict(ramons, flatten=False): """ Converts a RAMON object list to a JSON-style dictionary. Useful for going from an array of RAMONs to a dictionary, indexed by ID. Arguments: ramons (RAMON[]): A list of RAMON objects flatten (boolean: False): Not implemented Returns: ...
def to_json(ramons, flatten=False): """ Converts RAMON objects into a JSON string which can be directly written out to a .json file. You can pass either a single RAMON or a list. If you pass a single RAMON, it will still be exported with the ID as the key. In other words: type(from_json(to_...
def from_json(json, cutout=None): """ Converts JSON to a python list of RAMON objects. if `cutout` is provided, the `cutout` attribute of the RAMON object is populated. Otherwise, it's left empty. `json` should be an ID-level dictionary, like so: { 16: { type: "segme...
def from_hdf5(hdf5, anno_id=None): """ Converts an HDF5 file to a RAMON object. Returns an object that is a child- -class of RAMON (though it's determined at run-time what type is returned). Accessing multiple IDs from the same file is not supported, because it's not dramatically faster to access e...
def to_hdf5(ramon, hdf5=None): """ Exports a RAMON object to an HDF5 file object. Arguments: ramon (RAMON): A subclass of RAMONBase hdf5 (str): Export filename Returns: hdf5.File Raises: InvalidRAMONError: if you pass a non-RAMON object """ if issubclass(ty...
def RAMON(typ): """ Takes str or int, returns class type """ if six.PY2: lookup = [str, unicode] elif six.PY3: lookup = [str] if type(typ) is int: return _ramon_types[typ] elif type(typ) in lookup: return _ramon_typ...
def get_xy_slice(self, token, channel, x_start, x_stop, y_start, y_stop, z_index, resolution=0): """ Return a binary-encoded, decompressed 2d image. You should specify a 'token' and 'channel' pair. For image dat...
def get_volume(self, token, channel, x_start, x_stop, y_start, y_stop, z_start, z_stop, resolution=1, block_size=DEFAULT_BLOCK_SIZE, neariso=False): """ Get a RAMONVolume volumetric cutout f...
def get_cutout(self, token, channel, x_start, x_stop, y_start, y_stop, z_start, z_stop, t_start=0, t_stop=1, resolution=1, block_size=DEFAULT_BLOCK_SIZE, neariso=False): """ ...
def post_cutout(self, token, channel, x_start, y_start, z_start, data, resolution=0): """ Post a cutout to the server. Arguments: token (str) channel (str) x_s...
def create_project(self, project_name, dataset_name, hostname, is_public, s3backend=0, kvserver='localhost', kvengine='MySQL', mdengine=...
def create_token(self, token_name, project_name, dataset_name, is_public): """ Creates a token with the given parameters. Arguments: project_name (str): Project name dataset_name (str): Da...
def get_token(self, token_name, project_name, dataset_name): """ Get a token with the given parameters. Arguments: project_name (str): Project name dataset_name (str): Dataset name project is based on token...
def delete_token(self, token_name, project_name, dataset_name): """ Delete a token with the given parameters. Arguments: project_name (str): Project name dataset_name (str): Dataset name project is based on ...
def create_dataset(self, name, x_img_size, y_img_size, z_img_size, x_vox_res, y_vox_res, z_vox_res, x_offset=0, y...
def create_channel(self, channel_name, project_name, dataset_name, channel_type, dtype, startwindow, endwindow, readonly=0, ...
def get_channel(self, channel_name, project_name, dataset_name): """ Gets info about a channel given its name, name of its project , and name of its dataset. Arguments: channel_name (str): Channel name project_name (str): Project name dataset_name (st...
def delete_channel(self, channel_name, project_name, dataset_name): """ Deletes a channel given its name, name of its project , and name of its dataset. Arguments: channel_name (str): Channel name project_name (str): Project name dataset_name (str): D...
def add_channel(self, channel_name, datatype, channel_type, data_url, file_format, file_type, exceptions=None, resolution=None, windowrange=None, readonly=None): """ Arguments: channel_name (str): Channel Name is the specific name of a ...
def add_project(self, project_name, token_name=None, public=None): """ Arguments: project_name (str): Project name is the specific project within a dataset's name. If there is only one project associated with a dataset then standard convention is to name the ...
def add_dataset(self, dataset_name, imagesize, voxelres, offset=None, timerange=None, scalinglevels=None, scaling=None): """ Add a new dataset to the ingest. Arguments: dataset_name (str): Dataset Name is the overarching name of the research effor...
def nd_json(self, dataset, project, channel_list, metadata): """ Genarate ND json object. """ nd_dict = {} nd_dict['dataset'] = self.dataset_dict(*dataset) nd_dict['project'] = self.project_dict(*project) nd_dict['metadata'] = metadata nd_dict['channels'] ...
def dataset_dict( self, dataset_name, imagesize, voxelres, offset, timerange, scalinglevels, scaling): """Generate the dataset dictionary""" dataset_dict = {} dataset_dict['dataset_name'] = dataset_name dataset_dict['imagesize'] = imagesize dataset_dict['voxel...
def channel_dict(self, channel_name, datatype, channel_type, data_url, file_format, file_type, exceptions, resolution, windowrange, readonly): """ Generate the project dictionary. """ channel_dict = {} channel_dict['channel_name'] = chann...
def project_dict(self, project_name, token_name, public): """ Genarate the project dictionary. """ project_dict = {} project_dict['project_name'] = project_name if token_name is not None: if token_name == '': project_dict['token_name'] = projec...
def identify_imagesize(self, image_type, image_path='/tmp/img.'): """ Identify the image size using the data location and other parameters """ dims = () try: if (image_type.lower() == 'png'): dims = np.shape(ndpng.load('{}{}'.format( ...
def verify_path(self, data, verifytype): """ Verify the path supplied. """ # Insert try and catch blocks try: token_name = data["project"]["token_name"] except: token_name = data["project"]["project_name"] channel_names = list(data["channe...
def put_data(self, data): """ Try to post data to the server. """ URLPath = self.oo.url("autoIngest/") # URLPath = 'https://{}/ca/autoIngest/'.format(self.oo.site_host) try: response = requests.post(URLPath, data=json.dumps(data), ...
def post_data(self, file_name=None, legacy=False, verifytype=VERIFY_BY_SLICE): """ Arguments: file_name (str): The file name of the json file to post (optional). If this is left unspecified it is assumed the data is in the AutoIngest object. ...
def output_json(self, file_name='/tmp/ND.json'): """ Arguments: file_name(str : '/tmp/ND.json'): The file name to store the json to Returns: None """ complete_example = ( self.dataset, self.project, self.channels, self.metadata) data =...
def find_path(name, config, wsonly=False): """Find path for given workspace and|or repository.""" workspace = Workspace(config) config = config["workspaces"] path_list = {} if name.find('/') != -1: wsonly = False try: ws, repo = name.split('/') except ValueError...
def get_public_tokens(self): """ Get a list of public tokens available on this server. Arguments: None Returns: str[]: list of public tokens """ r = self.remote_utils.get_url(self.url() + "public_tokens/") return r.json()
def get_public_datasets_and_tokens(self): """ NOTE: VERY SLOW! Get a dictionary relating key:dataset to value:[tokens] that rely on that dataset. Arguments: None Returns: dict: relating key:dataset to value:[tokens] """ datasets =...
def get_proj_info(self, token): """ Return the project info for a given token. Arguments: token (str): Token to return information for Returns: JSON: representation of proj_info """ r = self.remote_utils.get_url(self.url() + "{}/info/".format(tok...
def get_image_size(self, token, resolution=0): """ Return the size of the volume (3D). Convenient for when you want to download the entirety of a dataset. Arguments: token (str): The token for which to find the dataset image bounds resolution (int : 0): The resol...
def set_metadata(self, token, data): """ Insert new metadata into the OCP metadata database. Arguments: token (str): Token of the datum to set data (str): A dictionary to insert as metadata. Include `secret`. Returns: json: Info of the inserted ID (c...
def add_subvolume(self, token, channel, secret, x_start, x_stop, y_start, y_stop, z_start, z_stop, resolution, title, notes): """ Adds a new subvolume to a token/channel. Arguments: token (str): ...
def get_url(self, url): """ Get a response object for a given url. Arguments: url (str): The url make a get to token (str): The authentication token Returns: obj: The response object """ try: req = requests.get(url, header...
def post_url(self, url, token='', json=None, data=None, headers=None): """ Returns a post resquest object taking in a url, user token, and possible json information. Arguments: url (str): The url to make post to token (str): The authentication token j...
def delete_url(self, url, token=''): """ Returns a delete resquest object taking in a url and user token. Arguments: url (str): The url to make post to token (str): The authentication token Returns: obj: Delete request object """ if (...
def ping(self, url, endpoint=''): """ Ping the server to make sure that you can access the base URL. Arguments: None Returns: `boolean` Successful access of server (or status code) """ r = self.get_url(url + "/" + endpoint) return r.status...
def load(hdf5_filename): """ Import a HDF5 file into a numpy array. Arguments: hdf5_filename: A string filename of a HDF5 datafile Returns: A numpy array with data from the HDF5 file """ # Expand filename to be absolute hdf5_filename = os.path.expanduser(hdf5_filename) ...
def save(hdf5_filename, array): """ Export a numpy array to a HDF5 file. Arguments: hdf5_filename (str): A filename to which to save the HDF5 data array (numpy.ndarray): The numpy array to save to HDF5 Returns: String. The expanded filename that now holds the HDF5 data """ ...
def run(self, job: Job) -> Future[Result]: ''' return values of execute are set as result of the task returned by ensure_future(), obtainable via task.result() ''' if not self.watcher_ready: self.log.error(f'child watcher unattached when executing {job}') job.canc...
def infer_gaps_in_tree(df_seq, tree, id_col='id', sequence_col='sequence'): """Adds a character matrix to DendroPy tree and infers gaps using Fitch's algorithm. Infer gaps in sequences at ancestral nodes. """ taxa = tree.taxon_namespace # Get alignment as fasta alignment = df_seq.phylo.to_...
def nvim_io_recover(self, io: NvimIORecover[A]) -> NvimIO[B]: '''calls `map` to shift the recover execution to flat_map_nvim_io ''' return eval_step(self.vim)(io.map(lambda a: a))
def read_codeml_output( filename, df, altall_cutoff=0.2, ): """Read codeml file. """ # Read paml output. with open(filename, 'r') as f: data = f.read() # Rip all trees out of the codeml output. regex = re.compile('\([()\w\:. ,]+;') trees = regex.findall(data) anc...
def ugettext(message, context=None): """Always return a stripped string, localized if possible""" stripped = strip_whitespace(message) message = add_context(context, stripped) if context else stripped ret = django_ugettext(message) # If the context isn't found, we need to return the string withou...
def ungettext(singular, plural, number, context=None): """Always return a stripped string, localized if possible""" singular_stripped = strip_whitespace(singular) plural_stripped = strip_whitespace(plural) if context: singular = add_context(context, singular_stripped) plural = add_conte...
def install_jinja_translations(): """ Install our gettext and ngettext functions into Jinja2's environment. """ class Translation(object): """ We pass this object to jinja so it can find our gettext implementation. If we pass the GNUTranslation object directly, it won't have our ...
def activate(locale): """ Override django's utils.translation.activate(). Django forces files to be named django.mo (http://code.djangoproject.com/ticket/6376). Since that's dumb and we want to be able to load different files depending on what part of the site the user is in, we'll make our own fu...
def tweak_message(message): """We piggyback on jinja2's babel_extract() (really, Babel's extract_* functions) but they don't support some things we need so this function will tweak the message. Specifically: 1) We strip whitespace from the msgid. Jinja2 will only strip whitespace from...
def exclusive_ns(guard: StateGuard[A], desc: str, thunk: Callable[..., NS[A, B]], *a: Any) -> Do: '''this is the central unsafe function, using a lock and updating the state in `guard` in-place. ''' yield guard.acquire() log.debug2(lambda: f'exclusive: {desc}') state, response = yield N.ensure_failu...
def _percent(data, part, total): """ Calculate a percentage. """ try: return round(100 * float(data[part]) / float(data[total]), 1) except ZeroDivisionError: return 0
def _get_cache_stats(server_name=None): """ Get stats info. """ server_info = {} for svr in mc_client.get_stats(): svr_info = svr[0].split(' ') svr_name = svr_info[0] svr_stats = svr[1] svr_stats['bytes_percent'] = _percent(svr_stats, 'bytes', 'limit_maxbytes') ...
def _get_cache_slabs(server_name=None): """ Get slabs info. """ server_info = {} for svr in mc_client.get_slabs(): svr_info = svr[0].split(' ') svr_name = svr_info[0] if server_name and server_name == svr_name: return svr[1] server_info[svr_name] = svr[1] ...
def _context_data(data, request=None): """ Add admin global context, for compatibility with Django 1.7 """ try: return dict(site.each_context(request).items() + data.items()) except AttributeError: return data
def server_status(request): """ Return the status of all servers. """ data = { 'cache_stats': _get_cache_stats(), 'can_get_slabs': hasattr(mc_client, 'get_slabs'), } return render_to_response('memcache_admin/server_status.html', data, RequestContext(request))
def dashboard(request): """ Show the dashboard. """ # mc_client will be a dict if memcached is not configured if not isinstance(mc_client, dict): cache_stats = _get_cache_stats() else: cache_stats = None if cache_stats: data = _context_data({ 'title': _('M...
def stats(request, server_name): """ Show server statistics. """ server_name = server_name.strip('/') data = _context_data({ 'title': _('Memcache Statistics for %s') % server_name, 'cache_stats': _get_cache_stats(server_name), }, request) return render_to_response('me...
def slabs(request, server_name): """ Show server slabs. """ data = _context_data({ 'title': _('Memcache Slabs for %s') % server_name, 'cache_slabs': _get_cache_slabs(server_name), }, request) return render_to_response('memcache_admin/slabs.html', data, RequestContext(requ...
def human_bytes(value): """ Convert a byte value into a human-readable format. """ value = float(value) if value >= 1073741824: gigabytes = value / 1073741824 size = '%.2f GB' % gigabytes elif value >= 1048576: megabytes = value / 1048576 size = '%.2f MB' % megaby...
def find_config(self, children): """ Find a config in our children so we can fill in variables in our other children with its data. """ named_config = None found_config = None # first see if we got a kwarg named 'config', as this guy is special if 'config...
def add(self, **kwargs): """ Add objects to the environment. """ for key in kwargs: if type(kwargs[key]) == str: self._children[key] = Directory(kwargs[key]) else: self._children[key] = kwargs[key] self._children[key]._e...
def apply_config(self, applicator): """ Replace any config tokens in the file's path with values from the config. """ if type(self._fpath) == str: self._fpath = applicator.apply(self._fpath)
def path(self): """ Get the path to the file relative to its parent. """ if self._parent: return os.path.join(self._parent.path, self._fpath) else: return self._fpath
def read(self): """ Read and return the contents of the file. """ with open(self.path) as f: d = f.read() return d