Skip to content
Snippets Groups Projects
Commit 299f803a authored by Bryan BRANCOTTE's avatar Bryan BRANCOTTE
Browse files

transmit dataTable name to fetch phenotypes

parent 2d8f4db9
Branches
Tags
No related merge requests found
...@@ -45,7 +45,11 @@ Please select the traits you want to analyze jointly with the Omnibus test. A re ...@@ -45,7 +45,11 @@ Please select the traits you want to analyze jointly with the Omnibus test. A re
<script> <script>
export default { export default {
async asyncData({ $axios, params, $auth }) { async asyncData({ $axios, params, $auth }) {
const phenotypes = await $axios.$get('/phenotypes') const data = {
initTableName: "initTable.hdf5"
// initTableName: "initTableTest.hdf5"
};
const phenotypes = await $axios.$post('/phenotypes', data)
return { return {
phenotypes, phenotypes,
} }
......
# coding: utf-8 # coding: utf-8
from typing import List from typing import List, Optional
import pandas import pandas
from pydantic import BaseModel import re
from pydantic import BaseModel, validator
class Phenotype(BaseModel): class Phenotype(BaseModel):
...@@ -72,5 +73,17 @@ def get_available_phenotypes(init_file_path: str): ...@@ -72,5 +73,17 @@ def get_available_phenotypes(init_file_path: str):
return phenotypes return phenotypes
_initTableNamePattern = re.compile("^([A-Z]*[a-z]*-*\.?[0-9]*)+$")
class ProjectNameModel(BaseModel):
initTableName: Optional[str] = "initTable.hdf5"
@validator("initTableName")
def validate_path_injection(cls, value):
if not _initTableNamePattern.match(value):
raise ValueError(f"Prohibited char, only \"{_initTableNamePattern.pattern}\" allowed.")
return value
class PhenotypeIdList(BaseModel): class PhenotypeIdList(BaseModel):
phenotypeID: List[str] = [] phenotypeID: List[str] = []
...@@ -52,10 +52,10 @@ async def read_index(): ...@@ -52,10 +52,10 @@ async def read_index():
return RedirectResponse(url="/webui/") return RedirectResponse(url="/webui/")
@app.get("/api/phenotypes", response_model=List[Phenotype]) @app.post("/api/phenotypes", response_model=List[Phenotype])
def phenotypes_list(): def phenotypes_list(project_name: ProjectNameModel):
"""List phenotypes""" """List phenotypes"""
return get_available_phenotypes(os.path.join(config["DATA_DIR"], "initTable.hdf5")) return get_available_phenotypes(os.path.join(config["DATA_DIR"], project_name.initTableName))
@app.get("/api/initmeta") @app.get("/api/initmeta")
def inittable_meta(): def inittable_meta():
......
File added
...@@ -25,6 +25,30 @@ curl -I http://0.0.0.0:3001/phenotypes/ \ ...@@ -25,6 +25,30 @@ curl -I http://0.0.0.0:3001/phenotypes/ \
if [ "$(cat log/02-*.log | grep "200 OK" | wc -l)" == "0" ]; then exit 02; fi if [ "$(cat log/02-*.log | grep "200 OK" | wc -l)" == "0" ]; then exit 02; fi
echo "Test fetching phenotypes through API"
curl --location --request POST http://0.0.0.0:8080/api/phenotypes/ \
--header 'Content-Type: application/json' \
--data-raw '{"initTableName":"initTableTest1.hdf5"}' \
-o log/11-post-phenotypes.json \
1> log/11-post-phenotypes.log \
2> log/11-post-phenotypes.err
if [ "$(cat log/11-*.json | grep "Internal Server Error" | wc -l)" == "1" ]; then exit 11; fi
echo "Test fetching phenotypes through API"
curl --location --request POST http://0.0.0.0:8080/api/phenotypes/ \
--header 'Content-Type: application/json' \
--data-raw '{"initTableName":"initTable.hdf5"}' \
-o log/12-post-phenotypes.json \
1> log/12-post-phenotypes.log \
2> log/12-post-phenotypes.err
if [ "$(cat log/12-*.json | grep "Internal Server Error" | wc -l)" == "1" ]; then exit 12; fi
if [ "$(cat log/11-*.json)" == "$(cat log/12-*.json)" ]; then echo "should not be equal"; exit 12; fi
echo "Testing project creation" echo "Testing project creation"
curl --location --request POST 'http://0.0.0.0:8080/api/projects' \ curl --location --request POST 'http://0.0.0.0:8080/api/projects' \
--header 'Accept: text/html' \ --header 'Accept: text/html' \
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment