diff --git a/README.md b/README.md index 4c90cd6c..211eedac 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ OIDC_RP_CLIENT_SECRET='your_client_secret' ``` Please, bear in mind that the name of the user has to be the same that you used when creating the user in LS or in IDP, whatever the AAI method you are working with. -To give a user a certain type of response for their queries, please modify this file [response_type.yml](https://github.com/EGA-archive/beacon2-ri-api/blob/master/beacon/request/response_type.yml) adding the maximum type of response you want to allow every user. +To give a user a certain type of response for their queries, please modify this file [response_type.yml](beacon/request/response_type.yml) adding the maximum type of response you want to allow every user. Also, you will need to edit the file [conf.py](beacon/conf.py) and introduce the domain where your keycloak is being hosted inside **idp_url**. @@ -57,7 +57,7 @@ middlewares=[web.normalize_path_middleware(), middlewares.error_middleware, cors ``` ### Beacon security system -![Beacon security](https://github.com/EGA-archive/beacon2-ri-api/blob/develop/deploy/beacon_security.png?raw=true) +![Beacon security](deploy/beacon_security.png) ### Version notes diff --git a/beacon/response/build_response.py b/beacon/response/build_response.py index cc20875e..ff2567db 100644 --- a/beacon/response/build_response.py +++ b/beacon/response/build_response.py @@ -25,41 +25,17 @@ def build_meta(qparams: RequestParams, entity_schema: Optional[DefaultSchemas], } return meta -def build_response_summary(exists, qparams, num_total_results): - limit = qparams.query.pagination.limit - include = qparams.query.include_resultset_responses +def build_response_summary(exists, num_total_results): LOG.debug(num_total_results) - #if limit != 0 and limit < num_total_results: - if include == 'NONE': - if num_total_results is None: - return { - 'exists': exists - } - else: - return { - 'exists': exists, - 'numTotalResults': num_total_results - } - elif limit and num_total_results and limit < num_total_results: - if num_total_results is None: - return { - 'exists': exists - } - else: - return { - 'exists': exists, - 'numTotalResults': limit - } + if num_total_results is None: + return { + 'exists': exists + } else: - if num_total_results is None: - return { - 'exists': exists - } - else: - return { - 'exists': exists, - 'numTotalResults': num_total_results - } + return { + 'exists': exists, + 'numTotalResults': num_total_results + } def build_response_summary_by_dataset(exists, num_total_results, data): @@ -152,7 +128,7 @@ def build_beacon_resultset_response(data, beacon_response = { 'meta': build_meta(qparams, entity_schema, Granularity.RECORD), - 'responseSummary': build_response_summary(num_total_results > 0, qparams, num_total_results), + 'responseSummary': build_response_summary(num_total_results > 0, num_total_results), # TODO: 'extendedInfo': build_extended_info(), 'response': { 'resultSets': [build_response(data, num_total_results, qparams, func_response_type)] @@ -198,7 +174,7 @@ def build_beacon_count_response(data, beacon_response = { 'meta': build_meta(qparams, entity_schema, Granularity.COUNT), - 'responseSummary': build_response_summary(num_total_results > 0, qparams, num_total_results), + 'responseSummary': build_response_summary(num_total_results > 0, num_total_results), # TODO: 'extendedInfo': build_extended_info(), 'beaconHandovers': beacon_handovers(), } @@ -219,7 +195,7 @@ def build_beacon_boolean_response(data, beacon_response = { 'meta': build_meta(qparams, entity_schema, Granularity.BOOLEAN), - 'responseSummary': build_response_summary(num_total_results > 0, qparams, None), + 'responseSummary': build_response_summary(num_total_results > 0, None), # TODO: 'extendedInfo': build_extended_info(), 'beaconHandovers': beacon_handovers(), } @@ -232,7 +208,7 @@ def build_beacon_boolean_response(data, def build_beacon_collection_response(data, num_total_results, qparams: RequestParams, func_response_type, entity_schema: DefaultSchemas): beacon_response = { 'meta': build_meta(qparams, entity_schema, Granularity.RECORD), - 'responseSummary': build_response_summary(num_total_results > 0, qparams, num_total_results), + 'responseSummary': build_response_summary(num_total_results > 0, num_total_results), # TODO: 'info': build_extended_info(), 'beaconHandovers': beacon_handovers(), 'response': { @@ -320,7 +296,7 @@ def build_filtering_terms_response(data, beacon_response = { 'meta': build_meta(qparams, entity_schema, Granularity.RECORD), - 'responseSummary': build_response_summary(num_total_results > 0, qparams, num_total_results), + 'responseSummary': build_response_summary(num_total_results > 0, num_total_results), # TODO: 'extendedInfo': build_extended_info(), 'response': { 'filteringTerms': data, diff --git a/deploy/README.md b/deploy/README.md index 0ba5b599..5c42c0ad 100644 --- a/deploy/README.md +++ b/deploy/README.md @@ -73,12 +73,12 @@ docker exec beacon python beacon/reindex.py #### List the ids -After deploying all the data, you will need to tell the beacon which are the individual and biosample ids belonging to each dataset and cohort. In order to do that, please, add the name of each dataset with the respective array of all the ids together in this file [datasets.yml](https://github.com/EGA-archive/beacon2-ri-api/blob/master/beacon/request/datasets.yml). -Then, repeat the same for the cohorts modifying this file [cohorts.yml](https://github.com/EGA-archive/beacon2-ri-api/blob/master/beacon/request/cohorts.yml). +After deploying all the data, you will need to tell the beacon which are the individual and biosample ids belonging to each dataset and cohort. In order to do that, please, add the name of each dataset with the respective array of all the ids together in this file [datasets.yml](../beacon/request/datasets.yml). +Then, repeat the same for the cohorts modifying this file [cohorts.yml](../beacon/request/cohorts.yml). #### Fetch the ontologies and extract the filtering terms -> This step consists of analyzing all the collections of the Mongo database for first extracting the ontology OBO files and then filling the filtering terms endpoint with the information of the data loaded in the database.∫ +> This step consists of analyzing all the collections of the Mongo database for first extracting the ontology OBO files and then filling the filtering terms endpoint with the information of the data loaded in the database. You can automatically fetch the ontologies and extract the filtering terms running the following script: diff --git a/frontend/README.md b/frontend/README.md index 05aba8ff..3a56b096 100644 --- a/frontend/README.md +++ b/frontend/README.md @@ -1,19 +1,24 @@ ## Deploy -Use the deployment for all the containers for beacon to also deploy the UI [Deployment](https://github.com/EGA-archive/beacon2-ri-api/blob/develop/deploy/README.md). You will find it running in http://localhost:3000 +Use the deployment for all the containers for beacon to also deploy the UI [Deployment](../deploy/README.md). You will find it running in http://localhost:3000 ## Instructions on how to configure the Beacon User Interface -Please first create a .env file inside the frontend folder so that you can modify some variables as follows: +Please first create a .env file inside the frontend folder so that you can modify some variables. Take into account that the file below will not be copied to GitHub as it contains keys and for security reasons it should ignored: ```bash REACT_APP_CLIENT_ID="ID of your LS Login" REACT_APP_CLIENT_SECRET="password of your LS Login" +REACT_APP_KEYCLOAK_CLIENT_SECRET="password of your Keycloak login" ``` -Take into account that the above file will not be copied to GitHub as it contains keys and for security reasons it should ignored. +You will need to have created your Life Science and Keycloak environments before. -Then please edit the file config.json, which can be found inside folder [frontend/src](https://github.com/EGA-archive/beacon2-ri-api/blob/develop/frontend/src/config.json). You need to decide where you want the UI to point to when making requests. Find below an example: +Tip: for Life Science environment, please first [create a user](https://lifescience-ri.eu/ls-login/users/how-to-get-and-use-life-science-id.html) . +After that you will need to register a service registry in order to be able to administrate your logins. Please go [here](https://services.aai.lifescience-ri.eu/spreg/) and ask for a New Service - type OIDC -. + + +Then please edit the file [config.json](src/config.json). You need to decide where you want the UI to point to when making requests. Find below an example: ```bash { @@ -21,4 +26,9 @@ Then please edit the file config.json, which can be found inside folder [fronten "REDIRECT_URL": "https://yourUIdomain.com", "KEYCLOAK_URL": "https://yourKEYCLOAKdomain.com" } -``` \ No newline at end of file +``` + +Finally, please include the URL of your User interface to the file beacon/_ main _.py (line 103), so that it becomes part of the list of URLs accepted by CORS. + + +Note that in the frontend folder you will find a file called .gitignore with the list of all files that need to be ignored.