Giter VIP home page Giter VIP logo

fio_wrapper's People

Contributors

dvorakdwarf avatar jplacht avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

fio_wrapper's Issues

[FEAT] Implement planet search endpoint: [POST] /planet/search

Allow users to search for planets by calling FIO endpoint /planet/search with a POST request: https://doc.fnar.net/#/planet/post_planet_search

Acceptance Criteria

  • Search is callable as fio.Planet.search() with search parameters passed
  • Optional search parameters default to False or empty list
  • Add validators
    • List[Materials] can't contain more than 3 Materials, all of them need to have valid form (max. 3 characters)
    • List[DistanceChecks] can't contain more than 3 Planets
  • Tests coverage at 100%
  • Call must include Workforce population (JobData) if authenticated
  • Call must return DistanceResults if authenticated

POST data

{
  "Materials": [
    "FEO",
    "LST"
  ],
  "IncludeRocky": true,
  "IncludeGaseous": true,
  "IncludeLowGravity": true,
  "IncludeHighGravity": false,
  "IncludeLowPressure": true,
  "IncludeHighPressure": false,
  "IncludeLowTemperature": true,
  "IncludeHighTemperature": false,
  "MustBeFertile": true,
  "MustHaveLocalMarket": true,
  "MustHaveChamberOfCommerce": false,
  "MustHaveWarehouse": true,
  "MustHaveAdministrationCenter": true,
  "MustHaveShipyard": false,
  "DistanceChecks": [
    "Katoa",
    "Promitor",
    "Montem"
  ]
}

FIO Limitations

  • Only the first 4 entries in the Materials array will be considered
  • Workforce populations (JobData) will not be present if not authenticated
  • DistanceResults will not be present if not authenticated
  • Only the first 3 entries in the DistanceChecks array will be considered

[FEAT] Requests Timeout Definition

Is your feature request related to a problem? Please describe.

FIO Wrapper currently does not set a timeout for requests towards FIO in case FIO is not responding:

# fio_adapter.py :: _do()

response = requests.request(
    method=http_method,
    url=endpoint,
    verify=self._ssl_verify,
    headers=self.headers(),
    params=params,
    json=data,
)

We should set one / allow setting one as FIO could be unavailable and the wrapper should not block all executions.

Describe the solution you'd like

  1. setting a fixed timeout in the Adapter
  2. allowing users to overwrite the standard timeout

Additional context

Python requests can set the timeout parameter on individual requests, however a Note mentions that this timeout is only related to the request receiving an response:

timeout is not a time limit on the entire response download; rather, an exception is raised if the server has not issued a response for timeout seconds (more precisely, if no bytes have been received on the underlying socket for timeout seconds). If no timeout is specified explicitly, requests do not time out.

Open points

  • Would it be required to set a timeout on a per-request level? E.g. setting a shorter timeout on Materials while Storage or GroupHub is able to wait longer on a FIO response?

[FEAT] Configuration files

Is your feature request related to a problem? Please describe.

Currently FIO Wrapper receives minor user input like api_key when FIO is instantiated. Things that might change due to a new API Version coming out, like URL endpoints are currently hard-coded in urls.py.

This should be changed to a configuration file approach where the wrapper brings its own base configuration and the user is allowed to overwrite them.

Examplary .ini base config structure

[FIO]
api_key = 12345
app_name = my wrapped app

[1.0.0.URL]
base = https://rest.fnar.com
material_base = /material
material_allmaterials = /allmaterials

Describe the solution you'd like

FIO Wrapper allows providing a config file on instantiation while keeping the "low effort" capability to just add a FIO API Key and Version number.

  • base_url moves into config depends on version
  • ssl_verification moves into config
  • app_name will be a required attribute either in FIO() or config , there is a fallback in base config of FIO Wrapper

[FEAT] Caching of requests

Is your feature request related to a problem? Please describe.

Currently all requests are executed against FIO endpoints while some of them have data that does not change on repeated execution. FIO has set up Cloudflare caching on their side, nevertheless it would be good to also cache requests from within FIO Wrapper instead of executing them.

Describe the solution you'd like

  • Implement functools with lru_cache (@functools.lru_cache) as decorator.
  • Integrate cache lifetimes in a configurable way so that the user could manually overwrite the standard settings

Additional context

[FEAT] Logging

Is your feature request related to a problem? Please describe.

Logging functionalities should be provided in fio_wrapper.

Describe the solution you'd like

Basic _do logging

Describe alternatives you've considered

loguru
structlog

Additional context

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.