Giter VIP home page Giter VIP logo

vdx-helper-python's Introduction

PyPI version Downloads

VDX Helper

This repository provides a wrapper for every call made to VDX Core Api.

How it works

This helper first needs to be authorized by wielding valid token from the authentication server, then use that token for further requests as long as it has not expired.

Each method also allows one to include their own custom mappers, enabling the method to return the result in the format the user wishes.

Prerequisites

  • Python Poetry
  • Docker + Docker-compose

Usage

Initialization

Required parameters:

  • api_url: The url leading to Core API server
  • auth_url: The url leading to authentication server
  • client_secret: The authentication secret
  • client_id: The ID of the client / partner
vdx_helper = VDXHelper(api_url='https://vizidox-core-api.com', auth_url='https://auth.com', client_secret=secret, client_id=client_id)

Mapper example

A mapper will receive a json-formatted parameter as their input. The following example mapper will add a field

def example_mapper(json_file):
    returned_json = copy.deepcopy(json_file)
    returned_json['additional_field'] = 'additional_value'
    return returned_json

Usage example

vdx_helper.upload_file(file=the_file_to_upload, mapper=example_mapper)

Running the tests

You can run the tests with poetry if you like. You can also obtain the code coverage.

poetry run pytest --cov=vdx_helper
  • Mypy:
poetry run mypy --config-file conf/mypy.ini vdx_helper
  • Coverage:
poetry run coverage run --source=vdx_helper -m pytest
poetry run coverage report
  • Tox:
tox -p

Run the test locally with docker-compose step-by-step

  1. Spin up the docker-containers
docker-compose up -d
  1. Run the tests via the vdx-helper docker container
docker-compose run vdx-helper pytest tests

Documentation

To build the documentation locally:

cd docs
make html

The build files can be found in docs/build. Open the generated index.html file in the html folder, and you can now navigate the documentation. Repeat the above command and refresh your browser every time you update the documentation. All source files are in docs/source, with vdx_helper containing the documentation generated from docstrings.

Authors

  • Tiago Santos - Initial work - Vizidox
  • Joana Teixeira - Corrections and improvements - Vizidox
  • Rita Mariquitos - Corrections and improvements - Vizidox

vdx-helper-python's People

Contributors

armarik avatar luned avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  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.