nidm package

Submodules

nidm.app module

class nidm.app.NIDMServer(*args, **kwargs)[source]

Bases: flask.app.Flask

class nidm.app.apiDoQuery[source]

Bases: flask_restful.Resource

return result of query on ttl file Paramters ========= qid: str

the uid associated with the query
ttl: str
the url of the turtle file
endpoint = 'apidoquery'
get(qid, output_format)[source]
mediatypes(resource_cls)
methods = ['GET']
class nidm.app.apiIndex[source]

Bases: flask_restful.Resource

Main view for REST API to display all available queries

endpoint = 'apiindex'
get()[source]
mediatypes(resource_cls)
methods = ['GET']
class nidm.app.apiQueryMeta[source]

Bases: flask_restful.Resource

return complete meta data for specific query

endpoint = 'apiquerymeta'
get(qid)[source]
mediatypes(resource_cls)
methods = ['GET']
nidm.app.generateQuery()[source]
nidm.app.newQuery()[source]
nidm.app.previewQuery()[source]
nidm.app.start(port=8088)[source]

nidm.experiment module

nidm.query module

query: part of the nidm-api general functions to work with query data structures for nidm-queries

class nidm.query.Queries(components=['experiment', 'results', 'workflow'])[source]
nidm.query.do_query(ttl_file, query, rdf_format='turtle', serialize_format='csv', output_df=True)[source]
nidm.query.download_queries(destination)[source]

Download queries repo to a destination Parameters ========== destination:

the full path to download the repo to
nidm.query.find_queries(query_folders, search_pattern='*.json')[source]

searches one or more folders for valid queries, meaning json files. In the case of multiple directories, will append the folder name as a variable to indicate the type Parameters ========== query_folders: list or str

one or more full paths to directories with json objects
search_pattern: str
pattern for glob to use to find query objects default is “*.json”
queries: list
a list of full paths to query object files
nidm.query.format_sparql(sparql_text)[source]

split sparql text into a list, and extract parameter options from select.

nidm.query.generate_query_template(output_dir=None, template_path=None, fields=None)[source]
output_dir: str
full path to output directory for json data structure. if none specified, will not save the data structure
template_path: str
path to json file to use as a template. Only should be specified if the user has reason to use a custom template default is the standard provided by nidm-api.
fields: dict (optional)
a dictionary with fields that correspond to template keys. if provided, template will be filled with keys. Possible values include
template: json (dict)
A python dictionary (json) that can be filled with new query information
nidm.query.get_query_directory(tmpdir=None)[source]

get_query_directory: Download queries repo to tmp directory Parameters ========== tmpdir: str

path to directory to download queries to
nidm.query.make_lookup(query_list, key_field)[source]

returns dict object to quickly look up query based on uid Parameters ========== query_list: list

a list of query (dict objects)
key_field: str
the key in the dictionary to base the lookup key
query_dict: dict
dict (json) with key as “key_field” from query_list
nidm.query.read_queries(query_paths)[source]

Read in a list of query (json) objects. Parameters ========== query_paths: list a list of full paths to query objects to read Returns ======= queries_: list

dict to be served as json describing queries available a “type” variable is added to indicate folder query was found in
nidm.query.save_query_template(template, output_dir)[source]

generate_query_template Parameters ========== output_dir: string path

full path to output directory for json data structure. the template filename is generated from the uid variable
success: boolean
True if save was successful, false otherwise
nidm.query.validate_queries(query_dir, queries=None, components=['sparql'])[source]

returns json object with query data structures, and a field ‘valid’ to describe if query was valid Parameters ========== queries: list

a list of full paths to json files, each a query
query_dir: str
full path to a nidm-query repo
components: folders to include corresponding to nidm
query language (currently only option is sparql)
queries: json
dict (json) with all read in queries available

from nidm-query, provided by API

nidm.results module

nidm.scripts module

script.py: part of nidmapi package Runtime executable

nidm.scripts.main()[source]

nidm.utils module

utils: part of the nidm-api general functions for the api

nidm.utils.clean_fields(mydict)[source]

Ensures that keys and values of dictionary are in utf-8 so rendering in javascript is clean. Paramters ========= mydict: dict

dictionary to clean
newdict: dict
dictionary with all fields encoded in utf-8
nidm.utils.copy_directory(src, dest)[source]

Copy an entire directory recursively

nidm.utils.find_directories(root, fullpath=True)[source]

Return directories at one level specified by user (not recursive)

nidm.utils.find_subdirectories(basepath)[source]

Return directories (and sub) starting from a base

nidm.utils.get_installdir()[source]

returns installation directory of nidm-api

nidm.utils.get_query_template()[source]

get_standard_template returns the full path to the standard template for queries

nidm.utils.get_template(template_file)[source]

get_template: read in and return a template file

nidm.utils.has_internet_connectivity()[source]

Checks for internet connectivity by way of trying to retrieve google IP address. Returns True/False

nidm.utils.is_type(var, types=[<type 'int'>, <type 'float'>, <type 'list'>])[source]

Check type

nidm.utils.load_json(json_path)[source]

returns a loaded json file Parameters ========== json_path: str

full path to json file to load
thejson: json (dict)
loaded json (dict)
nidm.utils.remove_unicode_dict(input_dict, encoding='utf-8')[source]

remove unicode keys and values from dict, encoding in utf8

nidm.utils.save_template(output_file, html_snippet)[source]
nidm.utils.set_permissions(path, permission=128)[source]
nidm.utils.sub_template(template, template_tag, substitution)[source]

make a substitution for a template_tag in a template

nidm.workflow module

Module contents