{ "info": { "author": "Colin Nolan", "author_email": "colin.nolan@sanger.ac.uk", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)", "Operating System :: OS Independent", "Programming Language :: Python :: 3.5" ], "description": "|Build Status| |codecov.io| # baton Python Wrapper\n\nIntroduction\n------------\n\nPython 3 Wrapper for `baton `__,\nsuperseding a [previous implementation in metadata-check]\n(https://github.com/wtsi-hgi/metadata-check/blob/9cd5c41b0f2e254fc1d6249a14752bd428587bb7/irods\\_baton/baton\\_wrapper.py).\n\nThe wrapper provides access to most of baton's functionality.\n\nHow to use\n----------\n\nPrerequisites\n~~~~~~~~~~~~~\n\n- Python >= 3.5.2\n- baton >= 0.16.4\n- iRODS >= 4.1.9\n\n*Note: Although older version of baton/iRODS will probably work, the\nlibrary is only aimed at the versions specified above.*\n\nInstallation\n~~~~~~~~~~~~\n\nStable releases can be installed via\n`PyPI `__:\n\n.. code:: bash\n\n $ pip3 install baton\n\nBleeding edge versions can be installed directly from GitHub:\n\n.. code:: bash\n\n $ pip3 install git+https://github.com/wtsi-hgi/python-baton-wrapper.git@#egg=baton\n\nTo declare this library as a dependency of your project, add it to your\n``requirement.txt`` file.\n\nAPI\n~~~\n\nSetup\n^^^^^\n\nTo use the iRODS API, you must first define a \"connection\" to an iRODS\nserver:\n\n.. code:: python\n\n from baton.api import connect_to_irods_with_baton, Connection\n\n # Setup connection to iRODS using baton\n irods = connect_to_irods_with_baton(\"/where/baton/binaries/are/installed/\", skip_baton_binaries_validation=False) # type: Connection\n\nData Objects and Collections\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\nThe API provides the ability to retrieve models of the data objects and\ncollections stored on an iRODS server. Similarly to the JSON that baton\nprovides, the models do not contain the payloads. They do however\nprovide access to all of the information that baton can retrieve about\nan entity, including Access Control Lists (ACLs), custom metadata\n(AVUs), the content of collections and information about data object\nreplicas. All methods provide the option to not load AVUs.\n\n.. code:: python\n\n from baton.models import DataObject, Collection, SearchCriterion, ComparisonOperator\n\n # Get models of data objects or collections at the given path(s) in iRODS\n irods.data_object.get_by_path(\"/collection/data_object\", load_metadata=False) # type: DataObject:\n irods.collection.get_by_path([\"/collection\", \"/other_collection\"]) # type: Sequence[Collection]:\n\n # Setup search for data objects or collections based on their metadata\n search_criterion_1 = SearchCriterion(\"attribute\", \"match_value\", ComparisonOperator.EQUALS)\n search_criterion_2 = SearchCriterion(\"other_attribute\", \"other_match_value\", ComparisonOperator.LESS_THAN)\n # Do search to get models of data objects or collections\n irods.data_object.get_by_metadata(search_criterion_1, zone=\"OptionalZoneRestriction\") # type: Sequence[DataObject]\n irods.collection.get_by_metadata([search_criterion_1, search_criterion_2], load_metadata=False) # type: Sequence[Collection]\n\n # Get models of data objects or collections contained within a collection(s)\n irods.collection.get_all_in_collection(\"/collection\", load_metadata=False) # type: Sequence[Collection]\n irods.data_object.get_all_in_collection([\"/collection\", \"/other_collection\"]) # type: Sequence[DataObject]\n\nMetadata (AVUs)\n^^^^^^^^^^^^^^^\n\nThe API provides the ability to both retrieve and manipulate the custom\nmetadata (AVUs) associated with data objects and collections.\n\n*Warning: there is currently no support for reading/writing the unit\nproperty of AVUs.*\n\nAlthough the type of metadata is the same for both data objects and\ncollections, due to the way iRODS works, it is necessary to know the\ntype of entity that a path corresponds to in order to retrieve metadata.\n\n.. code:: python\n\n from baton.collections import IrodsMetadata\n\n metadata_1 = IrodsMetadata({\"key\": {\"value_1\"}})\n metadata_2 = IrodsMetadata({\"another_key\": {\"value_1\", \"value_2\"}})\n\n # Metadata (methods available for both `data_object` and `collection`)\n irods.data_object.metadata.get_all(\"/collection/data_object\") # type: IrodsMetadata\n irods.collection.metadata.get_all([\"/collection\", \"/other_collection\"]) # type: Sequence[IrodsMetadata]\n\n # `metadata_1` is added to the data object with the first path in the list and `metadata_2` is added to the second\n irods.data_object.metadata.add([\"/collection/data_object\", \"/other_data_object\"], [metadata_1, metadata_2])\n irods.collection.metadata.add(\"/collection\", metadata_1)\n\n irods.data_object.metadata.set(\"/collection/data_object\", metadata_1)\n # `metadata_1` is added to both collections in the list\n irods.collection.metadata.set([\"/collection\", \"/other_collection\"], metadata_1)\n\n irods.data_object.metadata.remove([\"/collection/data_object\", \"/other_data_object\"], [metadata_1, metadata_2])\n irods.collection.metadata.remove(\"/collection\", metadata_1)\n\n irods.data_object.metadata.remove_all(\"/collection/data_object\")\n irods.collection.metadata.remove_all([\"/collection\", \"/other_collection\"])\n\nAccess Control Lists (ACLs)\n^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\nThe API provides the ability to both retrieve and manipulate the access\ncontrol lists (ACLs) associated with data objects and collections.\n\n.. code:: python\n\n from baton.models import AccessControl\n\n # ACLs. Note: it is implied that the owner is in the same zone as the entity to which the access control is applied\n acl_examples = [\n AccessControl(User(\"user_1\", \"zone_user_is_in\"), AccessControl.Level.READ),\n AccessControl(User(\"group_1\", \"zone_group_is_in\"), AccessControl.Level.WRITE),\n AccessControl(\"user_1#zone_user_is_in\", AccessControl.Level.OWN)\n ]\n\n irods.data_object.access_control.get_all(\"/collection/data_object\") # type: Set[AccessControl]\n irods.collection.access_control.get_all([\"/collection\", \"/another/collection\"]) # type: List[Set[AccessControl]]\n\n irods.data_object.access_control.add_or_replace([\"/collection/data_object\", \"/another/data_object\"], acl_examples[0])\n irods.collection.access_control.add_or_replace(\"/collection\", acl_examples, recursive=True)\n\n irods.data_object.access_control.set(\"/collection/data_object\", acl_examples[1])\n irods.collection.access_control.set([\"/collection\", \"/another/collection\"], acl_examples[0], recursive=False)\n\n irods.data_object.access_control.revoke([\"/collection/data_object\", \"/another/data_object\"], acl_examples)\n irods.collection.access_control.revoke(\"/collection\", acl_examples[1], recursive=True)\n\n irods.data_object.access_control.revoke_all([\"/collection/data_object\", \"/another/data_object\"])\n irods.collection.access_control.revoke_all(\"/collection\", recursive=True)\n\nCustom objects via specific queries\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\niRODS supports specific queries which return new types of object. In\norder to use such custom objects in iRODS via this library, a custom\nmodel of the object should to be made. Then, a subclass of\n``BatonCustomObjectMapper`` needs to be defined to specify how a\nspecific query (or number of specific queries) can be used to retrieve\nfrom and/or modify the object in iRODS.\n\nThe API provides the ability to retrieve the queries that are installed\non an iRODS server (ironically, by use of a specific query!):\n\n.. code:: python\n\n from baton.models import SpecificQuery\n\n # Get specific queries that have been installed on the iRODS server\n irods.specific_query.get_all(zone=\"OptionalZoneRestriction\") # type: Sequence[SpecificQuery]\n\nJSON Serialization/Deserialization\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\nThere are JSON encoders and decoders for nearly all iRODS object models\nin this library. These can be used to convert models to/from their baton\ndefined JSON representations. All serializers/deserializers extend\n``JSONEncoder`` and ``JSONDecoder`` (most through use of the\n`hgijson `__ library) meaning\nthat they can be used with `Python's built in ``json``\npackage `__:\n\n.. code:: python\n\n import json\n from baton.json import DataObjectJSONEncoder, DataObjectJSONDecoder, CollectionJSONEncoder, CollectionJSONDecoder, IrodsMetadataJSONEncoder, IrodsMetadataJSONDecoder, AccessControlJSONEncoder, AccessControlJSONDecoder\n\n data_object_as_json_string = json.dumps(data_object, cls=DataObjectJSONEncoder) # type: str\n data_object = json.loads(data_object_as_json_string, cls=DataObjectJSONDecoder) # type: DataObject\n\n collection_as_json_string = json.dumps(collection, cls=CollectionJSONEncoder) # type: str\n collection = json.loads(collection_as_json_string, cls=CollectionJSONDecoder) # type: Collection\n\n metadata_as_json_string = json.dumps(metadata, cls=IrodsMetadataJSONEncoder) # type: str\n metadata = json.loads(metadata_as_json_string, cls=IrodsMetadataJSONDecoder) # type: IrodsMetadata\n\n acl_as_json_string = json.dumps(metadata, cls=AccessControlJSONEncoder) # type: str\n acl = json.loads(acl_as_json_string, cls=AccessControlJSONDecoder) # type: List[AccessControl]\n\nDevelopment\n-----------\n\nSetup\n~~~~~\n\nInstall both library dependencies and the dependencies needed for\ntesting:\n\n.. code:: bash\n\n $ pip3 install -q -r requirements.txt\n $ pip3 install -q -r test_requirements.txt\n\n*A baton installation is not required.*\n\nSome tests use `Docker `__ therefore a Docker\ndaemon must be running on the test machine, with the environment\nvariables ``DOCKER_TLS_VERIFY``, ``DOCKER_HOST`` and\n``DOCKER_CERT_PATH`` set.\n\nTesting\n~~~~~~~\n\nUsing nosetests, in the project directory, run:\n\n.. code:: bash\n\n $ nosetests -v --cover-inclusive --tests baton/tests, baton/tests/_baton\n\nTo generate a test coverage report with nosetests:\n\n.. code:: bash\n\n $ nosetests -v --with-coverage --cover-package=baton --cover-inclusive --tests baton/tests, baton/tests/_baton\n\nLicense\n-------\n\n`LGPL license `__.\n\nCopyright (c) 2015, 2016 Genome Research Limited\n\n.. |Build Status| image:: https://travis-ci.org/wtsi-hgi/python-common.svg\n :target: https://travis-ci.org/wtsi-hgi/python-baton-wrapper\n.. |codecov.io| image:: https://codecov.io/gh/wtsi-hgi/python-baton-wrapper/graph/badge.svg\n :target: https://codecov.io/github/wtsi-hgi/python-baton-wrapper", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/wtsi-hgi/python-baton-wrapper", "keywords": null, "license": "LGPL", "maintainer": null, "maintainer_email": null, "name": "baton", "package_url": "https://pypi.org/project/baton/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/baton/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/wtsi-hgi/python-baton-wrapper" }, "release_url": "https://pypi.org/project/baton/1.0.1/", "requires_dist": null, "requires_python": null, "summary": "Python wrapper for baton.", "version": "1.0.1" }, "last_serial": 2414835, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "45cb3cd1be088488696089c88eb067d5", "sha256": "da78d99b8ec5005c665eee57e4a6c1de81217274c9ba4a7bd3270803e9b5ee9a" }, "downloads": -1, "filename": "baton-1.0.0.tar.gz", "has_sig": false, "md5_digest": "45cb3cd1be088488696089c88eb067d5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 34192, "upload_time": "2016-06-14T09:42:40", "url": "https://files.pythonhosted.org/packages/04/28/202a01f7d02db3fad259ec3f2ccc63b586329231c7e3584a186213663db2/baton-1.0.0.tar.gz" } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "cb3bc9202bca0e9f3be1a175137ddc33", "sha256": "76861bfa884b9a80333c5e3ac9d8636517e08ceeac4837c23e8d2bd700c5d8c6" }, "downloads": -1, "filename": "baton-1.0.1.tar.gz", "has_sig": false, "md5_digest": "cb3bc9202bca0e9f3be1a175137ddc33", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 36154, "upload_time": "2016-10-21T10:32:13", "url": "https://files.pythonhosted.org/packages/03/98/72ef7c700825986056b48243776a9152f9990e6c09ec4e3447e00c6804cb/baton-1.0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "cb3bc9202bca0e9f3be1a175137ddc33", "sha256": "76861bfa884b9a80333c5e3ac9d8636517e08ceeac4837c23e8d2bd700c5d8c6" }, "downloads": -1, "filename": "baton-1.0.1.tar.gz", "has_sig": false, "md5_digest": "cb3bc9202bca0e9f3be1a175137ddc33", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 36154, "upload_time": "2016-10-21T10:32:13", "url": "https://files.pythonhosted.org/packages/03/98/72ef7c700825986056b48243776a9152f9990e6c09ec4e3447e00c6804cb/baton-1.0.1.tar.gz" } ] }