Skip to content

A Simple helper library for consuming registers, indexes, and instances of classes exposed via a pyldapi endpoint.

License

Notifications You must be signed in to change notification settings

CSIRO-enviro-informatics/pyldapi-client

Repository files navigation

Welcome to pyLDAPI Client

The Python client library for the Python Linked Data API (pyLDAPI) is:

A Simple helper library for consuming registers, indexes, and instances of classes exposed via a pyLDAPI endpoint.

See the pyLDAPI module for more information.

PyPI Badge - coming soon

Example usage

from pyldapi_client import LDAPIClient

async def async_test_script(loop):
    remapper = {
        "http://test.linked.data.gov.au/dataset/asgs/": "http://13.236.122.60/asgs/sa4/"
    }
    base = "http://test.linked.data.gov.au/dataset/asgs/reg"
    client = await LDAPIClient(base, url_remapper=remapper, asynchronous=True, loop=loop)
    register = client.register("http://test.linked.data.gov.au/dataset/asgs/sa4/")
    first_page = await register.index_page(per_page=50)
    a = await register.index()
    instances = await register.instances(index=a, min_count=20)
    _ = await client.close()
    print(len(a))
    print(len(instances))
    return

def threaded_test_script():
    remapper = {
        "http://test.linked.data.gov.au/dataset/asgs/": "http://13.236.122.60/asgs/sa4/"
    }
    base = "http://test.linked.data.gov.au/dataset/asgs/reg"
    client = LDAPIClient(base, url_remapper=remapper, asynchronous=False, threads=8)
    register = client.register("http://test.linked.data.gov.au/dataset/asgs/sa4/")
    first_page = register.index_page(per_page=50)
    a = register.index()
    instances = register.instances(index=a, min_count=20)
    client.close()
    print(len(a))
    print(len(instances))
    return

def sync_test_script():
    remapper = {
        "http://test.linked.data.gov.au/dataset/asgs/": "http://13.236.122.60/asgs/sa4/"
    }
    base = "http://test.linked.data.gov.au/dataset/asgs/reg"
    client = LDAPIClient(base, url_remapper=remapper, asynchronous=False, threads=1)
    register = client.register("http://test.linked.data.gov.au/dataset/asgs/sa4/")
    first_page = register.index_page(per_page=50)
    a = register.index()
    instances = register.instances(index=a, min_count=20)
    client.close()
    print(len(a))
    print(len(instances))
    return


if __name__ == "__main__":
    import asyncio
    # For debugging/testing
    threaded_test_script()
    sync_test_script()
    loop = asyncio.get_event_loop()
    _a = async_test_script(loop)
    loop.run_until_complete(_a)

Documentation

Read the documentation at http://pyldapi-client.readthedocs.io/.

Implementations of pyLDAPI Client

  • LOC-I Index File Exporter

Licence

This module is licensed under Apache Software License v2.0. See the LICENSE deed for details.

Contact

Nicholas Car (lead)

Ashley Sommer (senior developer)

Informatics Software Engineer

About

A Simple helper library for consuming registers, indexes, and instances of classes exposed via a pyldapi endpoint.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages