Code Monkey home page Code Monkey logo

threedi-connector's Introduction

threedi-connector

Python client library for interacting with the 3Di API.

Install

$ pip install git+https://github.com/nens/threedi-connector.git

Use

Import the threedi_connector module:

>>> import threedi_connector

Start a simulation:

>>> simulation = threedi_connector.start_simulation(
...    model_slug='v2_bergermeer-v2_bergermeer_bres_maalstop-55-784c561ecebf9433cd7beb8b6a22a14f2841cda4',
...    organisation_uuid='61f5a464c35044c19bc7d4b42d7f58cb',
...    scenario_name='test-lib (this result can be deleted)',
...    start='2016-10-18T00:00',
...    end='2016-10-18T00:30')
Username: <your username>
Password: <your pw>

Get simulation task metadata using the returned Simulation object:

>>> simulation.info
{u'organisation_id': u'61f5a464c35044c19bc7d4b42d7f58cb',
 u'result_id': u'300f9ed8d1d54ff8b4def220a81060c8',
 u'status': u'received',
 u'subgrid_id': u'headless:1e0a2077d55044399a857c766e328645'}

Information from 3Di API can be requested using the Client. For example, getting the saved states and queued simulation:

>>> client = threedi_connector.Client()
>>> client.authenticate()  # authenticate once for this session
Username: <your username>
Password: <your pw>
>>> client.saved_states
[{'some': 'data', ...}, ...]
>>> sm.queued_tasks
[{'more': 'data', ...}, ...]

Interactive mode

Interactive mode is on by default. You can disable interactive prompts by authenticating using the .authenticate(username, password) method on Client or Simulation objects. Note: if you call .authenticate() without arguments, it will prompt for credentials.

To disable interactivity completely it is safer to just instantiate with interactive=False:

>>> client = threedi_connector.Client(interactive=False)
>>> simulation = threedi_connector.Simulation(interactive=False)

Running tests

$ python setup.py test

Design philosophy

Be good at doing one (or maybe two or three) thing(s).

A very simple API, with clear public and private classes/methods/functions. A simple API means also less need for thorough documentation.

As few dependencies as possible for maximum portability (ideally: 0; the current situation).

Designed for both Jupyter notebook use (therefore i.e. interactive authentication), and use as a library.

threedi-connector's People

Contributors

jackieleng avatar

Watchers

 avatar  avatar  avatar

threedi-connector's Issues

features

Main issue is that we have to get information from multiple sources to even start a simulation. To ease this there are some things we can do:

  • get all model slugs from api endpoint: e.g.: sim_manager.available_models
  • deduce organisation id from name (for convenience cuz people are lazy)?
  • implement filtering using DRF for saved states (i.e. we want to see what states are available)
  • make it easier to find rain raster UUIDs (using lizard-connector??)

Other long term features we would want (unrelated to previous point):

  • display all available parameters for the calculation endpoint
  • follow simulation progress
  • notify when simulation is complete?

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.