Skip to content

MJedr/inspirehep

 
 

Repository files navigation

Inspirehep

Pre requirements

Python

Python 3.6, 3.7

Debian / Ubuntu

$ sudo apt-get install python3 build-essential python3-dev

MacOS

$ brew install python

nodejs & npm using nvm

Please follow the instructions https://github.com/nvm-sh/nvm#installing-and-updating

We're using v10.14.0 (first version we install is the default)

$ nvm install 10.14.0

yarn

Debian / Ubuntu

Please folow the instructions https://classic.yarnpkg.com/en/docs/install/#debian-stable

MacOS

$ brew install yarn

poetry

install poetry https://poetry.eustace.io/docs/

$ curl -sSL https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py | python -

pre-commit

install pre-commit https://pre-commit.com/

$ curl https://pre-commit.com/install-local.py | python -

And run

$ pre-commit install

nginx

Debian / Ubuntu

Please follow the instractions https://www.nginx.com/resources/wiki/start/topics/tutorials/install/

$ apt-get update
$ apt-get install nginx

macOS:

$ brew install nginx

Add the following configuration:

server {
  listen 8080 default_server;
  server_name  _;

  location / {
    proxy_pass  http://localhost:3000/api;
    proxy_set_header Host localhost:3000;
    proxy_http_version 1.1;
  }

  location /api {
    proxy_pass         http://localhost:8000/api;
    proxy_set_header Host localhost:8000;
    proxy_http_version 1.1;
  }
}
  • On macOS /usr/local/etc/nginx/nginx.conf
  • On Debian / Ubuntu /etc/nginx/conf.d/default.conf

And reload nginx

$ nginx -s reload

Docker & Docker Compose

Follow the guide https://docs.docker.com/compose/install/


Installation

Backend

$ cd backend
$ poetry install

UI

$ cd ui
$ yarn install

Setup

First you need to start all the services (postgreSQL, Redis, ElasticSearch, RabbitMQ)

$ docker-compose -f docker-compose.travis.yml up -d

And initialize database and ES

$ cd backend
$ ./scripts/setup

Run

Backend

You can visit Backend http://localhost:8000

$ cd backend
$ ./scripts/server

UI

You can visit UI http://localhost:3000

$ cd ui
$ yarn start

You can also connect UI to another environment by changing the proxy a server by changing the ui/package.json

{
  ...
  "proxy": "http://A_PROXY_SERVER",
  ...
}

Both backend and UI are accessible http://localhost:8080


How to test

Backend

$ cd backend
$ ./run-tests.sh

Or you can run specific tests:

$ poetry run py.test tests/unit
$ poetry run py.test tests/integration
$ poetry run py.test tests/integration-async

Run Code Checks

Run isort and flake8 checks.

$ ./run-code-checks.sh

UI tests (unit and ui-tests)

$ cd ui
$ yarn test # in ui folder

e2e

$ ./run-e2e.sh

script tests

For script tests we're using cypress https://docs.cypress.io/

$ cd smoke-tests
$ yarn install
$ yarn run cypress:open # UI
$ yarn run cypress:run  # cmd interface

How to import records

First make sure that you are running:

$ cd backend
$ ./scripts/server

There is a command inspirehep importer records which accepts url -u, a directory of JSON files -d and JSON files -f. A selection of demo records can be found in data directory and they are structure based on the record type (i.e. literature). Examples:

With url

# Local
$ poetry run inspirehep importer records -u https://labs.inspirehep.net/api/literature/20 -u https://labs.inspirehep.net/api/literature/1726642
# Docker
$ ./docker-inspire run --rm web poetry run inspirehep importer records -u https://labs.inspirehep.net/api/literature/20 -u https://labs.inspirehep.net/api/literature/1726642

With directory

# Local
$ poetry run inspirehep importer records -d data/records/literature
# Docker
$ ./docker-inspire run --rm web poetry run inspirehep importer records -d data/records/literature

With files

# Local
$ poetry run inspirehep importer records -f data/records/literature/374836.json -f data/records/authors/999108.json
# Docker
$ ./docker-inspire run --rm web poetry run inspirehep importer records -f data/records/literature/374836.json -f data/records/authors/999108.json

About

inspirehep frontoffice

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 56.6%
  • JavaScript 40.4%
  • HTML 2.2%
  • CSS 0.4%
  • Shell 0.3%
  • TeX 0.1%