#+TITLE: sparcur developer guide
#+AUTHOR: Tom Gillespie
#+OPTIONS: num:nil ^:nil
#+LATEX_HEADER: \usepackage[margin=1.0in]{geometry}
#+STARTUP: showall

* Demos
** Remote only connection
This is the simplest way to get a remote only connection to Blackfynn
#+BEGIN_SRC python
from sparcur.paths import BlackfynnCache, Path
from sparcur.config import auth
from sparcur.backends import BlackfynnRemote
organization_id = auth.get('blackfynn-organization')
BlackfynnRemote = BlackfynnRemote._new(Path, BlackfynnCache)
BlackfynnRemote.init(organization_id)
root = BlackfynnRemote(BlackfynnRemote.root)
datasets = list(root.children)
return datasets
#+END_SRC
** Validate a dataset
You can run this example block and it will validate the DatasetTemplate. \\
To see the full results =from pprint import pprint=
and change the last line to =pprint(data)=.
#+BEGIN_SRC python :results output :exports both
from sparcur import pipelines as pipes
from sparcur.paths import Path


def makeValidator(dataset_path):
    class context:
        path = dataset_path.resolve()
        id = path.id
        uri_api = path.as_uri()
        uri_human = path.as_uri()

    class lifters:
        id = context.id
        folder_name = context.path.name
        uri_api = context.uri_api
        uri_human = context.uri_human

    return pipes.SPARCBIDSPipeline(dataset_path, lifters, context)


path = Path('../resources/DatasetTemplate')
pipeline = makeValidator(path)
data = pipeline.data
print(sorted(data.keys()))
#+END_SRC

#+RESULTS:
: ['dirs', 'errors', 'files', 'id', 'inputs', 'meta', 'samples', 'size', 'subjects']
