def validate_queries(query_dir,queries=None): '''validate_queries 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 Returns ======= queries: json dict (json) with all read in queries available from nidm-query, provided by API ''' #TODO: validation should include testing sparql, # as well as if fields possible to return are # possible given the query. It would be more ideal # to remove these "hard coded" options and have them # derived directly from the query at runtime if queries == None: query_folders = find_directories(query_dir) query_paths = find_queries(query_folders) queries = read_queries(query_paths) #TODO: need to decide how to validate :) return queries
def validate_queries(query_dir, queries=None, components=["results", "experiment", "workflow"]): '''validate_queries 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 folders: folders to include corresponding to nidm data structure subtypes (results, experiment, workflow) Returns ======= queries: json dict (json) with all read in queries available from nidm-query, provided by API ''' component_folders = [] if isinstance(components, str): components = [components] for folder in components: if folder in ["results", "experiment", "workflow"]: component_folders.append("%s/%s" % (query_dir, folder)) #TODO: validation should include testing sparql, # as well as if fields possible to return are # possible given the query. It would be more ideal # to remove these "hard coded" options and have them # derived directly from the query at runtime if queries == None: query_folders = find_directories(query_dir) if len(component_folders) > 0: query_folders = [ q for q in query_folders if q in component_folders ] query_paths = find_queries(query_folders) queries = read_queries(query_paths) #TODO: need to decide how to validate :) return queries
def validate_queries(query_dir,queries=None,components=["sparql"]): '''validate_queries 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) Returns ======= queries: json dict (json) with all read in queries available from nidm-query, provided by API ''' component_folders = [] if isinstance(components,str): components = [components] for folder in components: if folder in ["sparql"]: component_folders.append("%s/%s" %(query_dir,folder)) #TODO: validation should include testing sparql, # as well as if fields possible to return are # possible given the query. It would be more ideal # to remove these "hard coded" options and have them # derived directly from the query at runtime if queries == None: query_folders = find_directories(query_dir) if len(component_folders) > 0: query_folders = [q for q in query_folders if q in component_folders] query_paths = find_queries(query_folders) queries = read_queries(query_paths) #TODO: need to decide how to validate :) return queries