{ "info": { "author": "Raphael Ritz", "author_email": "raphael.ritz@incf.org", "bugtrack_url": null, "classifiers": [ "Programming Language :: Python", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "====================================\nINCF Digital Atlasing Infrastructure\n====================================\n\nThis package provides a Python API to the Digital Brain Atlasing web\nservices provided by the International Neuroinformatics Coordinating \nFacility (INCF_). To be useful and functional it requires a working\ninternet connection at runtime. The details of the core webservices \nwithin the INCF Digital Atlasing Infrastructure (incf.dai) are available \nfrom the specification_.\n\nTo explore the functioanlity of this package interactively it is strongly\nrecommended to use an enhanced interactive Python interpreter like\nIPython_ or bpython_.\n\n\nDiscovering and Accessing Hubs\n==============================\n\nIn a nutshell the INCF DAI consistes of a network of so-called\n*hubs* providing whatever services the group managing the hub decided\nto share. To discover available hubs there is a utility function\n\n>>> from incf.dai.utils import list_hub_names\n>>> sorted(list_hub_names())\n['aba', 'central', 'emap', 'ucsd', 'whs']\n\nThis provides a list of currently known hub names. (Note: atm the list\nis provided by the package since the INCF central hub managing the\nregistry is a fast moving target still.)\n\nKnowing the names of available hubs one can optain proxy objects\nspecific for a particular hub by calling\n\n>>> from incf.dai.utils import get_hub_by_name\n>>> whs = get_hub_by_name('whs')\n>>> whs # doctest: +ELLIPSIS\n\n\nIf you call for an unknow hub (or make a typo) you will get a ``KeyError``\n\n>>> foo = get_hub_by_name('foo')\nTraceback (most recent call last):\nKeyError\n\nFor introspection the URL to the service controller for this hub is\navailable as \n\n>>> whs.base_url\n'http://incf-dev-local.crbs.ucsd.edu/whs/atlas?service=WPS'\n\nThere are two methods all hubs are expected to provide:\n\n>>> whs.GetCapabilities # doctest: +ELLIPSIS\n\n\n>>> whs.DescribeProcess # doctest: +ELLIPSIS\n\n\nCalling any of those methods returns a custom response object\n\n>>> response = whs.GetCapabilities()\n>>> response # doctest: +ELLIPSIS\n\n\n>>> response = whs.DescribeProcess()\n>>> response # doctest: +ELLIPSIS\n\n\nUsually, there is no need to call any of the two methods mentioned \nabove as their main information returned is available anyway via\n\n>>> sorted(whs.capabilities)\n[u'DescribeSRS', u'GetStructureNamesByPOI', u'ListSRSs', u'ListTransformations', u'TransformPOI']\n\nand all methods listed are available on the hub proxy right away\n\n>>> sorted(whs.__dict__.keys()) # doctest: +NORMALIZE_WHITESPACE\n['DescribeSRS', 'GetStructureNamesByPOI', 'ListSRSs',\n'ListTransformations', 'TransformPOI', 'base_url', \n'capabilities', 'process_descriptions', 'proxy']\n\nlike in \n\n>>> response = whs.ListSRSs()\n>>> sorted(response.keys()) # doctest: +NORMALIZE_WHITESPACE\n[u'service', u'serviceInstance', u'version', u'wps_Process', \nu'wps_ProcessOutputs', u'wps_Status', u'xml_lang', u'xmlns_ogc', \nu'xmlns_ows', u'xmlns_wps', u'xmlns_xlink', u'xmlns_xsi', \nu'xsi_schemaLocation']\n\n>>> response['wps_ProcessOutputs']['wps_Output']['wps_Data']['wps_ComplexData']['ListSRSResponse']['SRSCollection']['SRSList'] # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE\n{SRS:[{Area:{structureName:u'Whole Brain'}, \n Author:{authorCode:u'WHS', ...\n\nFor further convenience, the response object also supports attribute-like \naccess to the data as in\n\n>>> response.wps_Status # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE\n{creationTime:...\n\nNote how the namespaces are preserved as prefixes of the key and attribute names.\n\nOmitting required arguments raises an ``ApplicationError``\n\n>>> response = whs.DescribeSRS() # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE\nTraceback (most recent call last):\n...\nApplicationError: \nCode: NoApplicableCode\nText: Unexpected exception occured\nURL: http://incf-dev-local.crbs.ucsd.edu/whs/atlas?service=WPS&version=1.0.0&request=Execute&Identifier=DescribeSRS&ResponseForm=xml\n\nwhereas calling a method correctly gives and appropriate response (hopefully)\n\n>>> response = whs.GetStructureNamesByPOI(format=None, srsName=\"Mouse_paxinos_1.0\", x='1', y='4.3', z='1.78') # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE\n>>> response.keys()\n[u'xmlns_xlink', u'wps_Process', u'xml_lang', u'wps_Status', u'wps_ProcessOutputs', u'service', u'xmlns_xsi', u'xmlns_ows', u'xsi_schemaLocation', u'version', u'xmlns_ogc', u'xmlns_wps', u'serviceInstance']\n>>> response.wps_ProcessOutputs.wps_Output.wps_Data.wps_ComplexData.StructureTermsResponse.StructureTerms.StructureTerm.Code.data\nu'Cx'\n\nThe ``format=None`` here works around issue\nhttp://code.google.com/p/incf-dai/issues/detail?id=14\n\n\nThe Response in detail\n======================\n\nThe custom response object returned from service calls provides\na variety of useful information like the HTTP response headers\n\n>>> sorted(response.headers.keys()) # doctest: +NORMALIZE_WHITESPACE\n['connection', 'content-location', 'content-type', 'date', 'status', \n'transfer-encoding']\n\nand for convenience there is a short-cut to the content type\n\n>>> response.content_type\n'text/xml;charset=UTF-8'\n\nThe source of the returned response page is available as\n\n>>> response.content # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE\n'\\n...\n\nwhich is probably more readable when printed (for this doc test\ncalling ``print response`` is avoided but in an interactive session \nit should work just fine)\n\n>>> str(response) # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE\n'>> type(response.data)\n\n\nwhich acts like a nested dictionary \n\n>>> response.data.keys() # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE\n[u'xmlns_xlink', u'wps_Process', u'xml_lang', u'wps_Status', \nu'wps_ProcessOutputs', u'service', u'xmlns_xsi', u'xmlns_ows', \nu'xsi_schemaLocation', u'version', u'xmlns_ogc', u'xmlns_wps', \nu'serviceInstance']\n\n>>> wps_Data = response.data['wps_ProcessOutputs']['wps_Output']['wps_Data']\n>>> wps_Data['wps_ComplexData']['StructureTermsResponse']['StructureTerms'] # doctest: +NORMALIZE_WHITESPACE\n{StructureTerm:{Code:{codeSpace:u'Mouse_paxinos_1.0', \nisDefault:u'true', data:u'Cx'}, Description:u'Term - Cx\nderived from WHS hub based on the supplied POI.', Name:''}, hubCode:u'WHS'}\n\nbut also supports attribute-like access (as long as the keys don't\ncontain characters that make them unsuited as attribute names - in\nthose cases only subscription access works)\n\n>>> response.data.xmlns_xsi\nu'http://www.w3.org/2001/XMLSchema-instance'\n\nAgain for convenience, the ``data`` attribute can be bypassed\nas the ``data`` content is lifted\" to the response object itself\n\n>>> response.data.keys() == response.keys()\nTrue\n\nand\n\n>>> response.xmlns_xsi\nu'http://www.w3.org/2001/XMLSchema-instance'\n\nDigging deeper into the response data requires knowledge of\nthe response schema which is available from http://incf.org/WaxML\nor introspection of the content of the ``response.data`` attribute.\n\n\nImproving Performance\n=====================\n\nAccessing a hub by calling ``get_hub_by_name`` as presented above \ntriggers calling ``DescribeProcess`` on hub proxy initialization to \ninfer the hubs capabilities and to dynamically create methods making \nthose capabilities readily available on the hub proxy. \nDepending on context and intended usage you may want to avoid that \noverhead and rather prefer a \"naked\" hub proxy as in\n\n>>> whs_minimal = get_hub_by_name('whs', minimal=True)\n\nThis avoids calling ``DescribeProcess`` on initialization but in\nreturn all you are left with is the generic call method that\nrequires you to pass all arguments needed to construct the \nproper WPS request\n\n>>> response = whs_minimal(version='1.0.0', request='Execute', identifier='ListSRSs')\n>>> sorted(response.keys()) # doctest: +NORMALIZE_WHITESPACE \n[u'service', u'serviceInstance', u'version', u'wps_Process',\nu'wps_ProcessOutputs', u'wps_Status', u'xml_lang', u'xmlns_ogc',\nu'xmlns_ows', u'xmlns_wps', u'xmlns_xlink', u'xmlns_xsi',\nu'xsi_schemaLocation']\n\nOnce you know what you need to call from your own code you\nmay prefer this approach.\n\n\nLogging\n=======\n\nPer default, all service calls are logged at ``INFO`` level to a custom log \nfile (``incf.dai.log``)in the current working directory including a time stamp, \nthe package name, the log level and the URL called.\n\n\nAccessing Hubs not registered at INCF\n=====================================\n\nTo connect to a hub not registered with INCF Central (e.g., a local\nhub under development) one can instanciate the proxy explicitly as in \n(setting ``offline=True`` avoids ever calling the url)\n\n>>> from incf.dai.hub import HubProxy\n>>> myhub = HubProxy('http://some.url?service=WPS', offline=True)\n>>> myhub # doctest: +ELLIPSIS\n\n\nAt the very least the generic call method to be invoked as in \n\n>>> capabilities = myhub(version=None, request='GetCapabilities')\nRequested URL: http://some.url?service=WPS&request=GetCapabilities&ResponseForm=xml\npositional arguments: ('GET',)\n\nshould always be available.\nThe first argument here is to override the version specification which\nis not supported for ``GetCapabilities`` calls. Second is the name of the \nrequest to be invoked at the hub.\nFor convenience ``GetCapabilities`` is also provided as a method\non the hub proxy itself.\n\n>>> myhub.GetCapabilities() # doctest: +ELLIPSIS\nRequested URL: http://some.url?service=WPS&request=GetCapabilities&ResponseForm=xml\npositional arguments: ('GET',)\n\n\n\n\n.. _INCF: http://incf.org\n.. _specification: http://code.google.com/p/incf-dai/wiki/INCFProjectSpecification\n.. _IPython: http://ipython.scipy.org/moin/\n.. _bpython: http://bpython-interpreter.org/\n\nChangelog\n=========\n\n0.7 (2011-09-15)\n----------------\n\n- Update generic call and response handling to follow changes introduced\n by moving to Degree-based services for DAI proper. [raphael]\n\n\n0.6 (2010-09-26)\n----------------\n\n- Initial release\n the version number (0.6) refers to the INCF.DAI service specification\n underlying this release - this is still very much work in progress", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://software.incf.org/software/incfdai", "keywords": "WPS INCF \"Digital Atlasing\"", "license": "GPL", "maintainer": null, "maintainer_email": null, "name": "incf.dai", "package_url": "https://pypi.org/project/incf.dai/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/incf.dai/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://software.incf.org/software/incfdai" }, "release_url": "https://pypi.org/project/incf.dai/0.7/", "requires_dist": null, "requires_python": null, "summary": "Python API for the INCF Digital Atlasing infrastructure", "version": "0.7" }, "last_serial": 833374, "releases": { "0.6": [ { "comment_text": "", "digests": { "md5": "ff0ba0bb6ab880832e25cead12e22b81", "sha256": "27bd643d12f09d28133eb5505a7612fa97e6605b2394d20075d7fc460a8a3ff4" }, "downloads": -1, "filename": "incf.dai-0.6.tar.gz", "has_sig": false, "md5_digest": "ff0ba0bb6ab880832e25cead12e22b81", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13439, "upload_time": "2010-09-26T11:12:47", "url": "https://files.pythonhosted.org/packages/d3/1a/d5d4452a971bdfce8fe1c2248557f0c0a59639c07d4a6d06b9e487281740/incf.dai-0.6.tar.gz" } ], "0.7": [ { "comment_text": "", "digests": { "md5": "767f78ecddd7a5e96e1d7c380f1881cd", "sha256": "6c1f0c8d5c01ecb8fdae123254a44ddde8d54c04973edcdd4637e7748100d97a" }, "downloads": -1, "filename": "incf.dai-0.7.tar.gz", "has_sig": false, "md5_digest": "767f78ecddd7a5e96e1d7c380f1881cd", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15050, "upload_time": "2011-09-15T17:11:53", "url": "https://files.pythonhosted.org/packages/d7/a6/35a6557a1ef4f574c33a3ffb22ac247f3094b4b1bbdcd7904c82afc89162/incf.dai-0.7.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "767f78ecddd7a5e96e1d7c380f1881cd", "sha256": "6c1f0c8d5c01ecb8fdae123254a44ddde8d54c04973edcdd4637e7748100d97a" }, "downloads": -1, "filename": "incf.dai-0.7.tar.gz", "has_sig": false, "md5_digest": "767f78ecddd7a5e96e1d7c380f1881cd", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15050, "upload_time": "2011-09-15T17:11:53", "url": "https://files.pythonhosted.org/packages/d7/a6/35a6557a1ef4f574c33a3ffb22ac247f3094b4b1bbdcd7904c82afc89162/incf.dai-0.7.tar.gz" } ] }