Skip to content

mnezh/h2o-homework

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A homework for H2O.ai, based on REQUIREMENTS.md

Prerequisites

A UNIX-like system with:

Installation

  1. clone repository
  2. in the cloned directory, run
make install

It should create a virtualenv with Python 2.7, install all the dependencies and a pre-commit hook.

Testing

make lint should execute the pycodestyle (former PEP8) checks on the code.

make test should execute the py.test and genarate spec-like output (using pytest-spec)

Running

make run should start Flask API instance:

$ make run
pipenv run src/app.py
 * Serving Flask app "Reuters API" (lazy loading)
 * Environment: production
   WARNING: Do not use the development server in a production environment.
   Use a production WSGI server instead.
 * Debug mode: on
 * Running on http://127.0.0.1:9666/ (Press CTRL+C to quit)
 * Restarting with stat
 * Debugger is active!

Endpoints

  • /article/<newid> - returns article by newid primary key
  • /articles[?filter1=value&filter1=value] - returns a list of articles, optionally filtered by the filters:
    • exact match filters:
      • cgisplit
      • lewissplit
      • newid
      • topics
      • oldid
    • list filters (field should have all values):
      • meta.companies
      • meta.exchanges
      • meta.orgs
      • meta.people
      • meta.places
      • meta.topics
    • full-text filters (field should contain text):
      • text.body
      • text.dateline
      • text.title
    • date filters (article date should match one of):
      • day - same day of month
      • month - same month
      • year - same year
      • date - same date

Examples

Get article number 100 (i.e. newid is 100):

curl http://127.0.0.1:9666/article/100

Get all articles from 1987:

curl http://127.0.0.1:9666/article\?year\=1987

Get all articles about USA, Iran and Reagan from 1987:

curl http://127.0.0.1:9666/article\?year\=1987\&meta.people\=reagan\&meta.places\=iran

Get all articles about USA, Iran and Reagan from 1987 which mention Texas:

curl http://127.0.0.1:9666/article\?year\=1987\&meta.people\=reagan\&meta.places\=iran\&text.body\=Texas

About

Homework for the h2o.ai

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published