README.md 4.86 KB
Newer Older
Yohan Boniface's avatar
Yohan Boniface committed
1
# Trefle
Yohan Boniface's avatar
Yohan Boniface committed
2

David Foucher's avatar
David Foucher committed
3 4 5
## Présentation du projet

  Trèfle est un simulateur de dispositifs de financement qui, en fonction des données du demandeur et de la formation, va générer une liste de financements possibles.
David Foucher's avatar
David Foucher committed
6
  Cette liste de financements proposés est accompagnée, selon le dispositif, de la rémunération dont pourrait bénéficier le demandeur. Les résultats sont donnés à titre informatif et nécessitent l'accompagnement d'un conseiller pour la suite des démarches.
David Foucher's avatar
David Foucher committed
7 8 9

## Project overview

David Foucher's avatar
David Foucher committed
10
  Trèfle is a simulator tool aim to propose a list of financial plans depending on buyer situation employment data and training courses data itself. A renumeration can be proposed with the formation plan. Results are given as information only and must be accompanied by an adviser to engage the process of any plan.
David Foucher's avatar
David Foucher committed
11 12 13 14 15 16

## Dependencies

- LBF Url to simulation on the web interface explorer
- LBF Catalog API key to retrieve training courses data

David Foucher's avatar
David Foucher committed
17
### Python3 dependencies for dev mode
Yohan Boniface's avatar
Yohan Boniface committed
18

David Foucher's avatar
David Foucher committed
19 20 21 22 23 24 25 26
- python3-venv
- python3-dev
- python3-wheel

## Install in dev mode

- Create a venv : `python3 -m venv .venv`
- Activate the virtualenv : `source .venv/bin/activate`
27
- Then: `make develop`
Yohan Boniface's avatar
Yohan Boniface committed
28

David Foucher's avatar
David Foucher committed
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
### Add env var

    ```
    VERSION=api-vX.X.X
    OLD_VERSION=api-vX.X.X
    BACK_VERSION=backoffice-vX.X.X
    LBF_CHARMAP="sA,4B,RC,cD,oE,gF,yG,wH,mI,HJ,7K,EL,aM,YN,XO,8P,GQ,BR,kS,iT,IU,AV,TW,DX,pY,JZ,2a,Lb,Mc, d,de,Cf,Qg,fh,ri,Pj,Nk,Vl,vm,0n,Ko,ep,jq,Zr,9s,ht,Fu,tv,-w,Ux,1y,xz,30,u1,52,q3,W4,S5,66,n7,b8,O9,_+,l/,z "
    CATALOG_USER={ASK-YOUR-LBF-CATALOG-API-USER}
    CATALOG_KEY={ASK-YOUR-LBF-CATALOG-API-KEY}
    CATALOG_URL=https://labonneformation.pole-emploi.fr/api/v1/detail
    TREFLE_GIT=https://git.beta.pole-emploi.fr/open-source/trefle.git
    GITLAB_TOKEN={ASK-GITLAB-TOKEN}
    ```
### Local API server

    Launch dev mode server: `trefle serve`


### Run a simulation
Yohan Boniface's avatar
Yohan Boniface committed
48

David Foucher's avatar
David Foucher committed
49 50
  Swagger API DOC : https://app.swaggerhub.com/apis/labonneformation/moteur-financement-formation

Yohan Boniface's avatar
Yohan Boniface committed
51
    trefle simulate var=value var2=value2…
Yohan Boniface's avatar
Yohan Boniface committed
52 53
    # Or from an LBF URL
    trefle simulate --url=https://xxx?a=yyy
54 55 56 57
    # Or from JSON (like a request body from the logs)
    trefle simulate --context='{"xxx": "yyyy"}'
    # You can output a Gherkin scenario from this simulation
    trefle simulate var=value var2=value2… --output-scenario
Yohan Boniface's avatar
Yohan Boniface committed
58
    # Get details about the data (including retrieved data from catalog)
59
    trefle simulate var=value var2=value2… --show-context
Yohan Boniface's avatar
Yohan Boniface committed
60 61
    # Trace the rules to see which condition passed or failed
    trefle simulate var=value var2=value2… --trace
Yohan Boniface's avatar
Yohan Boniface committed
62

David Foucher's avatar
David Foucher committed
63 64 65
    Exemple:
    trefle simulate --context='{"beneficiaire":{"inscrit_pe":true,"age":40},"formation":{ "codes_financeur":[2],"region":27,"heures":4000}}' --trace

David Foucher's avatar
David Foucher committed
66
## Run the backoffice in dev mode
Yohan Boniface's avatar
Yohan Boniface committed
67

David Foucher's avatar
David Foucher committed
68 69 70 71
### configure
To connect the front to your API server in dev mode, change in backoffice/vue.config.js:

    `proxy: 'https://trefle.beta.pole-emploi.fr/0.7/'` for `proxy: 'http://127.0.0.1:3579/`
David Foucher's avatar
David Foucher committed
72

David Foucher's avatar
David Foucher committed
73
### launch
David Foucher's avatar
David Foucher committed
74 75

    cd backoffice
David Foucher's avatar
David Foucher committed
76 77 78 79
    npm install
    npm run serve

    and go to url : http://127.0.0.1:8080/explorer
Yohan Boniface's avatar
Yohan Boniface committed
80 81 82

## Run unittests

Yohan Boniface's avatar
Yohan Boniface committed
83
    py.test
Yohan Boniface's avatar
Yohan Boniface committed
84 85 86

## Run integration tests

Yohan Boniface's avatar
Yohan Boniface committed
87
    behave
Yohan Boniface's avatar
Yohan Boniface committed
88 89 90

Get a detailed coverage report:

Yohan Boniface's avatar
Yohan Boniface committed
91
    behave -D coverage-format=short
Yohan Boniface's avatar
Yohan Boniface committed
92 93 94

Get a more detailed coverage report:

Yohan Boniface's avatar
Yohan Boniface committed
95
    behave -D coverage-format=long
David Foucher's avatar
David Foucher committed
96 97 98

## Build project in PROD mode

David Foucher's avatar
David Foucher committed
99
1. Go to docker folder
David Foucher's avatar
David Foucher committed
100

David Foucher's avatar
David Foucher committed
101
2. Add this env var:
David Foucher's avatar
David Foucher committed
102

David Foucher's avatar
David Foucher committed
103
    ```
104 105 106 107 108 109 110 111 112
    VERSION=api-vX.X.X
    OLD_VERSION=api-vX.X.X
    BACK_VERSION=backoffice-vX.X.X
    LBF_CHARMAP="sA,4B,RC,cD,oE,gF,yG,wH,mI,HJ,7K,EL,aM,YN,XO,8P,GQ,BR,kS,iT,IU,AV,TW,DX,pY,JZ,2a,Lb,Mc, d,de,Cf,Qg,fh,ri,Pj,Nk,Vl,vm,0n,Ko,ep,jq,Zr,9s,ht,Fu,tv,-w,Ux,1y,xz,30,u1,52,q3,W4,S5,66,n7,b8,O9,_+,l/,z "
    CATALOG_USER={ASK-YOUR-LBF-CATALOG-API-USER}
    CATALOG_KEY={ASK-YOUR-LBF-CATALOG-API-KEY}
    CATALOG_URL=https://labonneformation.pole-emploi.fr/api/v1/detail
    TREFLE_GIT=https://git.beta.pole-emploi.fr/open-source/trefle.git
    GITLAB_TOKEN={ASK-GITLAB-TOKEN}
David Foucher's avatar
David Foucher committed
113 114
    ```

David Foucher's avatar
David Foucher committed
115 116 117 118

where X.X.X is a tag of the TREFLE_GIT
OLD_VERSION and BACK_VERSION must be compatible

119
3. Add email, password, and rule file authorized to be modified in docker/authorisations.csv
David Foucher's avatar
David Foucher committed
120
    i.e: `myname@email.com, mypassord, Occitanie.rules`
David Foucher's avatar
David Foucher committed
121

122
4. `docker-compose up --build -d` to use image from the gitlab registry or `docker-compose -f docker-compose.yml -f docker-compose.override-build.yml up -d --build` to build the image from scratch
David Foucher's avatar
David Foucher committed
123

David Foucher's avatar
David Foucher committed
124 125 126 127
## Update trefle

### Update API
1. Update `VERSION` in `.env` file
128
2. Update API, in `docker` folder process : `./update_api.sh trefle`
David Foucher's avatar
David Foucher committed
129 130 131

### Update WEB
1. Update `BACK_VERSION` in `.env` file
132
2. Update the website, in `docker` folder process : `./update_web.sh`
133 134 135 136 137

## Update acces

1. Update file authorisations.csv in docker/authorisations.csv
2. in docker folder do `sh update_access`
David Foucher's avatar
David Foucher committed
138
logs are in docker/logs
139 140 141 142

Format for authorisations.csv :
  `email,password,files`
Note: multiple files must be separated with a "|"
143 144 145 146 147 148

## Troubleshooting

Try to restart the stack with `./restart_stack.sh`