diff --git a/backend/src/upload.py b/backend/src/upload.py index 37020a1..3f8e620 100644 --- a/backend/src/upload.py +++ b/backend/src/upload.py @@ -185,7 +185,7 @@ def to_camelcase(s: str) -> str: s = sub(r"(_|-)+", " ", s).title().replace(" ", "") return "".join([s[0].lower(), s[1:]]) -def load_cohort_dict_file(dict_path: str, cohort_id: str, airlock: bool) -> Dataset: +def load_cohort_dict_file(dict_path: str, cohort_id: str) -> Dataset: """Parse the cohort dictionary uploaded as excel or CSV spreadsheet, and load it to the triplestore""" # print(f"Loading dictionary {dict_path}") # df = pd.read_csv(dict_path) if dict_path.endswith(".csv") else pd.read_excel(dict_path) @@ -219,8 +219,6 @@ def load_cohort_dict_file(dict_path: str, cohort_id: str, airlock: bool) -> Data g = init_graph() g.add((cohort_uri, RDF.type, ICARE.Cohort, cohort_uri)) g.add((cohort_uri, DC.identifier, Literal(cohort_id), cohort_uri)) - # Preview goes to mapping graph because it is defined in the explorer UI - g.add((cohort_uri, ICARE.previewEnabled, Literal(str(airlock).lower(), datatype=XSD.boolean), get_cohort_mapping_uri(cohort_id))) # Record all errors and raise them at the end errors = [] @@ -358,7 +356,9 @@ async def upload_cohort( shutil.copyfileobj(cohort_dictionary.file, buffer) try: - g = load_cohort_dict_file(metadata_path, cohort_id, airlock) + g = load_cohort_dict_file(metadata_path, cohort_id) + # Airlock preview setting goes to mapping graph because it is defined in the explorer UI + g.add((get_cohort_uri(cohort_id), ICARE.previewEnabled, Literal(str(airlock).lower(), datatype=XSD.boolean), get_cohort_mapping_uri(cohort_id))) # Delete previous graph for this file from triplestore delete_existing_triples(get_cohort_uri(cohort_id)) publish_graph_to_endpoint(g) @@ -467,7 +467,7 @@ def init_triplestore() -> None: for file in glob.glob(os.path.join(folder_path, "*_datadictionary.*")): # NOTE: default airlock preview to false if we ever need to reset cohorts, # admins can easily ddl and reupload the cohorts with the correct airlock value - g = load_cohort_dict_file(file, folder, False) + g = load_cohort_dict_file(file, folder) g.serialize(f"{settings.data_folder}/cohort_explorer_triplestore.trig", format="trig") if publish_graph_to_endpoint(g): print(f"💾 Triplestore initialization: added {len(g)} triples for cohorts {file}.") diff --git a/frontend/src/components/CohortsContext.tsx b/frontend/src/components/CohortsContext.tsx index 18995c4..e12fd1c 100644 --- a/frontend/src/components/CohortsContext.tsx +++ b/frontend/src/components/CohortsContext.tsx @@ -15,19 +15,6 @@ export const CohortsProvider = ({children}: any) => { const [userEmail, setUserEmail]: [string | null, any] = useState(''); const worker: MutableRefObject = useRef(null); - // Update cohorts data with a web worker in the background for smoothness - // const worker = new Worker('/cohortsWorker.js'); - // worker.onmessage = (event) => { - // // Update your state with the new data - // const data = event.data; - // if (!data.error) { - // setCohortsData(data); - // console.log('Updated context with data', data); - // } else { - // console.error('Error fetching data in worker:', data.error); - // } - // }; - useEffect(() => { setDataCleanRoom(JSON.parse(sessionStorage.getItem('dataCleanRoom') || '{"cohorts": {}}')); @@ -61,6 +48,7 @@ export const CohortsProvider = ({children}: any) => { // Fetch cohorts data from the API using the web worker const fetchCohortsData = () => { worker.current?.postMessage({apiUrl}); + // console.log(cohortsData) }; // Update the metadata of a specific cohort in the context diff --git a/frontend/src/components/Nav.tsx b/frontend/src/components/Nav.tsx index 8bc73fb..72904cc 100644 --- a/frontend/src/components/Nav.tsx +++ b/frontend/src/components/Nav.tsx @@ -36,11 +36,8 @@ export function Nav() { const toggleTheme = () => { const newTheme = theme === 'light' ? 'dark' : 'light'; - // console.log("NEW THEME", newTheme) sessionStorage.setItem('theme', newTheme); setTheme(newTheme); - // document.querySelector('html')?.setAttribute('data-theme', newTheme); - // document.documentElement.setAttribute("data-theme", newTheme); }; const handleLogout = () => { @@ -63,16 +60,7 @@ export function Nav() { const sendCohortsToDecentriq = async () => { setIsLoading(true); // Replace with actual API endpoint and required request format - console.log('Sending request to Decentriq', dataCleanRoom); - const requestBody = dataCleanRoom; - // const requestBody = {cohorts: {}}; - // for (const cohortId of dataCleanRoom.cohorts as string[]) { - // // @ts-ignore - // // requestBody.cohorts[cohortId] = cohortsData[cohortId]; - // // NOTE: variables is left empty for now, placeholder for later when users will be able to select also variables - // requestBody.cohorts[cohortId] = {"variables": []}; - // } - console.log('requestBody', requestBody); + // console.log('Sending request to Decentriq', dataCleanRoom); try { const response = await fetch(`${apiUrl}/create-dcr`, { method: 'POST', @@ -80,10 +68,10 @@ export function Nav() { headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify(requestBody) + body: JSON.stringify(dataCleanRoom) }); const res = await response.json(); - console.log(res); + // console.log(res); setPublishedDCR(res); setIsLoading(false); // Handle response