Code Monkey home page Code Monkey logo

nis-python-client's Introduction

Python client for NIS Backend

A Python client package to operate with NIS-Backend

NIS stands for "Nexus Information System". It is a software system (a set of software components) developed as part of project "MAGIC" activities (H2020 grant #689669). NIS-Backend is the main component, an engine capable of interpreting and resolving MuSIASEM (sustainability, water-energy-food nexus, bioeconomic) models expressed using a DSL in spreadsheet form. For more information go to nis-backend repository at Github.

Getting started

Prerequisites

  • Python 3.x
  • A NIS backend instance has to be running and accessible. The URL of the API endpoint is the required parameter for the construction of the client. See the example in "Basic Usage" section below. For instructions on executing nis-backend please check README.md at Github.

Installing

pip install nexinfosys-client

Basic Usage

from nexinfosys import NISClient

c = NISClient("http://localhost:5000/nis_api") # Construct client
c.login("test_user")  # Login, using test user
c.open_session()  # Open a session (needed before submission)
fname = "<path to XLSX specifying a case study (accessible to the Python interpreter executing this script)>"
c.load_workbook(fname)  # Load a workbook (see DMP's annex "Case study formatting reference") 
# Submit the workbook (execute, return a list of issues, if empty or no issues with type==3, successful execution)
r = c.submit()
success = sum([i.type==3 for i in r]) == 0
for i in r:  # Print issues
    print(str(i))
if success:
    r = c.query_available_datasets()  # Obtain available datasets
    if len(r) > 0:
        for ds in r:  # List available datasets
            print(str(ds))
        # Query for one of the datasets ("ds1" must exist)
        r = c.query_datasets([("ds1", "csv")])
        # Write datasets
        for cnt, f in enumerate(r):
            fd = open(f[0]+"."+f[1], "wb")
            fd.write(f[2])
            fd.close()

# Close session
c.close_session()
# Logout
c.logout()

Authors

  • Rafael Nebot. Instituto Tecnológico de Canarias, SA. Departamento de Computación

License

This project is licensed under the BSD-3 License - see the LICENSE file for details

Acknowledgements

The development of this software was supported by the European Union’s Horizon 2020 research and innovation programme under Grant Agreement No. 689669 (MAGIC). This work reflects the authors' view only; the funding agencies are not responsible for any use that may be made of the information it contains.

nis-python-client's People

Contributors

rnebot avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.