Giter Site home page Giter Site logo

public-annotations-api's Introduction

Public API for Annotations (public-annotations-api)

Circle CI Go Report Card Coverage Status

Provides a public API for Annotations stored in a Neo4J graph database

Installation & running locally

go get -u github.com/Financial-Times/public-annotations-api
cd $GOPATH/src/github.com/Financial-Times/public-annotations-api
go build -mod=readonly
./public-annotations-api

Command line options:

--neo-url            neo4j endpoint URL (env $NEO_URL) (default "bolt://localhost:7687")
--port               Port to listen on (env $PORT) (default "8080")
--env                environment this app is running in (default "local")
--cache-duration     Duration Get requests should be cached for. e.g. 2h45m would set the max-age value to '7440' seconds (env $CACHE_DURATION) (default "30s")
--log-level          Log level for the service (env $LOG_LEVEL) (default "info")
--dbDriverLogLevel   Db's driver logging level (DEBUG, INFO, WARN, ERROR) (env $DB_DRIVER_LOG_LEVEL) (default "WARN")
--api-yml            Location of the API Swagger YML file. (env $API_YML) (default "./api.yml")
  • curl http://localhost:8080/content/143ba45c-2fb3-35bc-b227-a6ed80b5c517/annotations | json_pp
  • Or using httpie http GET http://localhost:8080/content/143ba45c-2fb3-35bc-b227-a6ed80b5c517/annotations

Testing

  • Run unit tests only: go test -race ./...

  • Run unit and integration tests:

    In order to execute the integration tests you must provide GITHUB_USERNAME and GITHUB_TOKEN values, because the service is depending on internal repositories.

    GITHUB_USERNAME=<username> GITHUB_TOKEN=<token> \
    docker-compose -f docker-compose-tests.yml up -d --build && \
    docker logs -f test-runner && \
    docker-compose -f docker-compose-tests.yml down

Build & deployment

Continuously built by CircleCI. The docker image of the service is built by Dockerhub based on the git release tag. To prepare a new git release, go to the repo page on GitHub and create a new release.

API definition

Based on the following google doc

GET content/{uuid}/annotations endpoint

Returns all annotations for a given uuid of a piece of content in json format.

Please note that

  • the public-annotations-api will return more brands than the ones the article has been annotated with. This is because it will return also the parent of the brands from any brands annotations. If those brands have parents, then they too will be brought into the result.

  • the public-annotations-api uses annotations lifecycle to determine which annotations are returned. If curated (tag-me) annotations (lifecycle pac) for a piece of content exist, they will be returned combined with V2 annotations by default, other non-pac lifecycle annotations are omitted. If there are no pac lifecycle annotations, non-pac annotations will be returned. The filtering described in the next paragraph relates to non-pac annotations. Additional filtering by annotations lifecycle could be applied using the optional "lifecycle" query parameter.

  • the public-annotations-api will filter out less important annotations if a more important annotation is also present for the same concept.
    For example, if a piece of content is annotated with a concept with "About", "Major Mentions" and "Mentions" relationships only the annotation with "About" relationship will be returned. Similarly if a piece of content is annotated with a Concept "Is Classified By" and "Is Primarily Classified By" only the annotation with "Is Primarily Classified By" relationship will be returned.

Admin endpoints

Logging

Logging requires an env app parameter: for all environments other than local, logs are written to file. When running locally logging is written to console (if you want to log locally to file you need to pass in an env parameter that is != local).

NOTE: http://localhost:8080/__gtg end point is not logged as it is called every second from varnish and this information is not needed in logs/splunk

public-annotations-api's People

Contributors

adybach avatar agrancharova avatar asparuhft avatar bboykov avatar bernivarga avatar bot-tooling avatar carlosroman avatar dbelev avatar dtvalk-ov avatar ekaneva avatar elizhuh avatar epavlova avatar erdema-ft avatar galiri avatar geoah avatar georgi-denchew avatar ilian2233 avatar ivan-p-nikolov avatar ivanruski avatar izzyblues avatar juliafernee avatar manoelmilchev avatar mchompalova avatar peteclark-ft avatar rnov avatar sjwells avatar tamas-molnar avatar tosan88 avatar wheresrhys avatar yolandeleungft avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

public-annotations-api's Issues

Make majorMentions produce implicitlyAbout annotations

Currently when editors tag with about then the public annotations API derives implicitlyAbout based on the concepts that are transitively broader than the tagged concept.

Guy would like tagged majorMentions to have the same effect.

Example: 1a342680-0724-11e8-9650-9c0ad2d7c5b5 is about Glencore and majorMentions Mining among other things

Glencore has no broader so it does not get any implicityAbout
Guy would like the Mining to qualify as well so that it is implicitlyAbout topics like Energy and Companes

Doing this now will mean the transition to Tagme is more seamless, as the effect of republishing an article through Tagme will be to convert existing majorMentions to about. After this change this conversion will not affect the implicitlyAbout tags.

Not all the fields in the model are exposed therefore shouldn't be in the public model

annotations/models.go
@@ -14,6 +14,8 @@ type annotation struct {
TmeIDs []string json:"tmeIDs,omitempty"
UUIDs []string json:"uuids,omitempty"
PlatformVersion string json:"platformVersion,omitempty"

  • //used for filtering, e.g. pac not exposed
  • Lifecycle string

@nwrigh 25 minutes ago Member
It would have been nice that this model was for the exposed fields and the neoannotation representation was used for filtering before morphed into into a representation we are returning.

@galiri 12 minutes ago Member
fair point, but I'm reluctant to dive into that filtering code, maybe after it goes away

@nwrigh a minute ago Member
Don't blame you at all. I will add it as an issue and then maybe someone else has the appetite for this when they come to it

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.