Skip to content

Commit

Permalink
#1559, #1648 - jobs (#477)
Browse files Browse the repository at this point in the history
* removed SGC column from target list

* #1540 added preferred alias functionality

* #1540 added edit column to target list and use target settings modal

* #1540 updated "Open" label and read only version of display name

* Squashed commit of the following:

commit c5bba58
Author: Boris Kovar <boris.kovar@m2ms.sk>
Date:   Tue Dec 10 08:13:00 2024 +0100

    #1603 - fixes

* Squashed commit of the following:

commit 9d9bf8c
Author: Boris Kovar <boris.kovar@m2ms.sk>
Date:   Wed Dec 11 15:20:54 2024 +0100

    fixed frontend part of the ticket. Now properly resolves target based on the target name and target access string

* - fixed issue when the template protein is missing

* Squashed commit of the following:

commit 2fd529e
Author: Boris Kovar <boris.kovar@m2ms.sk>
Date:   Mon Dec 16 10:44:15 2024 +0100

    - changes labels in searchSettingsDialog

commit 12499a9
Author: Boris Kovar <boris.kovar@m2ms.sk>
Date:   Mon Dec 16 09:47:05 2024 +0100

    -small fix

commit cbf95f1
Merge: 5bd7756 900d851
Author: Boris Kovar <boris.kovar@m2ms.sk>
Date:   Thu Dec 12 13:34:14 2024 +0100

    Merge branch '#1563-LHS-search' of https://github.com/m2ms/fragalysis-frontend into #1563-LHS-search

commit 5bd7756
Author: Boris Kovar <boris.kovar@m2ms.sk>
Date:   Thu Dec 12 13:30:00 2024 +0100

    - search aliases

commit 3e7540f
Author: Boris Kovar <boris.kovar@m2ms.sk>
Date:   Tue Dec 10 12:12:03 2024 +0100

    - checkpoint

commit 6631373
Author: Boris Kovar <boris.kovar@m2ms.sk>
Date:   Fri Dec 6 10:05:51 2024 +0100

    - #1563 - all the UI and infrastructure and search by shortcode and compound id is done

commit 900d851
Author: Boris Kovar <boris.kovar@m2ms.sk>
Date:   Thu Dec 12 13:30:00 2024 +0100

    - search aliases

commit a72f427
Author: Boris Kovar <boris.kovar@m2ms.sk>
Date:   Tue Dec 10 12:12:03 2024 +0100

    - checkpoint

commit 4b7d699
Merge: 4579a9d 32c837d
Author: Boris Kovar <boris.kovar@m2ms.sk>
Date:   Tue Dec 10 10:26:34 2024 +0100

    Merge branch '#1563-LHS-search' of https://github.com/m2ms/fragalysis-frontend into #1563-LHS-search

commit 4579a9d
Author: Boris Kovar <boris.kovar@m2ms.sk>
Date:   Fri Dec 6 10:05:51 2024 +0100

    - #1563 - all the UI and infrastructure and search by shortcode and compound id is done

commit 32c837d
Author: Boris Kovar <boris.kovar@m2ms.sk>
Date:   Fri Dec 6 10:05:51 2024 +0100

    - #1563 - all the UI and infrastructure and search by shortcode and compound id is done

* - fixes #1622 and changes defaults for search settings

* Squashed commit of the following:

commit 021d6f2
Merge: a5fb901 182a10a
Author: boriskovar-m2ms <boris.kovar@m2ms.sk>
Date:   Thu Dec 19 13:49:43 2024 +0100

    Merge branch '#1533-direct-links' of https://github.com/m2ms/fragalysis-frontend into #1533-direct-links

commit a5fb901
Author: Boris Kovar <boris.kovar@m2ms.sk>
Date:   Tue Dec 17 16:56:49 2024 +0100

    - implements #1533

commit 182a10a
Author: Boris Kovar <boris.kovar@m2ms.sk>
Date:   Tue Dec 17 16:56:49 2024 +0100

    - implements #1533

* #1606 pose properties table from tooltip to separate icon

* added button to menu for getting session token

* #1552 use id for filtering datasets

* Squashed commit of the following:

commit 119bb81
Author: boriskovar-m2ms <boris.kovar@m2ms.sk>
Date:   Tue Feb 4 09:51:33 2025 +0100

    - last fixes

commit d8f9811
Author: boriskovar-m2ms <boris.kovar@m2ms.sk>
Date:   Wed Jan 29 12:55:31 2025 +0100

    - checkpoint

commit 55cf854
Author: Boris Kovar <boris.kovar@m2ms.sk>
Date:   Mon Jan 27 10:01:06 2025 +0100

    #1648 - resurrected fragmenstein combine with some additional misc fixes

---------

Co-authored-by: matej <matej.vavrek@m2ms.sk>
Co-authored-by: matej <60509086+matej-vavrek@users.noreply.github.com>
  • Loading branch information
3 people authored Feb 5, 2025
1 parent 96baab2 commit 9393305
Show file tree
Hide file tree
Showing 10 changed files with 189 additions and 119 deletions.
4 changes: 3 additions & 1 deletion docker-compose.dev.vector.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ services:
web:
container_name: web_dock
image: xchem/fragalysis-stack:latest
# image: alanbchristie/fragalysis-backend:1187.3
# image: xchem/fragalysis-backend:m2ms-1649-refresh-fix
# image: boriskovarm2ms/fragalysis-stack:experiment2
# image: kaliif/fragalysis-backend:latest
command: /bin/bash /code/launch-stack.sh
Expand Down Expand Up @@ -105,6 +105,8 @@ services:
DEPLOYMENT_MODE: 'development'
DISABLE_RESTRICT_PROPOSALS_TO_MEMBERSHIP: 'True'
PUBLIC_TAS: 'lb18145-1,lb32633-1'
WEB_DJANGO_SUPERUSER_PASSWORD: ${WEB_DJANGO_SUPERUSER_PASSWORD}
SQUONK2_REFRESH_SHOULD_RETRIEVE_RESULTS: 'Yes'
# INFECTIONS: 'structure-download'
depends_on:
database:
Expand Down
6 changes: 3 additions & 3 deletions js/components/datasets/datasetMoleculeList.js
Original file line number Diff line number Diff line change
Expand Up @@ -492,11 +492,11 @@ const DatasetMoleculeList = ({ title, datasetID, url }) => {
const isSelectedTypeOn = (typeList, isLHSReference) => {
if (typeList) {
if (!isLHSReference) {
return typeList.some(molId => allMolecules?.some(mol => mol.id === molId));
return typeList?.some(molId => allMolecules?.some(mol => mol.id === molId));
} else {
const molsWithLHSReference = allMolecules?.filter(mol => mol.site_observation_code);
return typeList.some(molId =>
molsWithLHSReference.some(
return typeList?.some(molId =>
molsWithLHSReference?.some(
mol => mol.site_observation_code === allMoleculesList?.find(m => m.id === molId)?.code
)
);
Expand Down
2 changes: 1 addition & 1 deletion js/components/preview/molecule/observationCmpList.js
Original file line number Diff line number Diff line change
Expand Up @@ -859,7 +859,7 @@ export const ObservationCmpList = memo(({ hideProjects }) => {
newMolsToEdit.push(cm.id);
}
});
if (newMolsToEdit.length !== moleculesToEditIds.length) {
if (newMolsToEdit.length !== moleculesToEditIds.length && allMoleculesList?.length > 0) {
dispatch(setMolListToEdit(newMolsToEdit));
}

Expand Down
120 changes: 66 additions & 54 deletions js/components/preview/projectHistoryPanel/JobConfigurationDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,15 @@ import {
} from '../../projects/redux/dispatchActions';
import { areArraysSame } from '../../../utils/array';
import { setDisableRedirect, setDontShowShareSnapshot } from '../../snapshot/redux/actions';
import { createNewSnapshot } from '../../snapshot/redux/dispatchActions';
import { changeSnapshot, createNewSnapshot } from '../../snapshot/redux/dispatchActions';
import { NglContext } from '../../nglView/nglProvider';
import moment from 'moment';
import { SnapshotType } from '../../projects/redux/constants';
import { DJANGO_CONTEXT } from '../../../utils/djangoContext';
import { VIEWS } from '../../../constants/constants';
import { getSquonkProject } from '../redux/dispatchActions';
import { extractRelativePath } from './utils';
import { base_data_url } from '../../routes/constants';

const useStyles = makeStyles(theme => ({
jobLauncherPopup: {
Expand Down Expand Up @@ -165,6 +167,8 @@ const JobConfigurationDialog = ({ snapshots }) => {
const [open, setOpen] = useState(false);
const [isError, setIsError] = useState(false);
const [errorMsg, setErrorMsg] = useState(null);
const [isLaunchButtonDisabled, setIsLaunchButtonDisabled] = useState(false);

const handleTooltipClose = () => {
setOpen(false);
};
Expand All @@ -174,7 +178,7 @@ const JobConfigurationDialog = ({ snapshots }) => {

const jobConfigurationDialogOpen = useSelector(state => state.projectReducers.jobConfigurationDialogOpen);

const getAllMolecules = useSelector(state => state.apiReducers.all_mol_lists);
const allMolecules = useSelector(state => state.apiReducers.all_mol_lists);
const allDatasets = useSelector(state => state.datasetsReducers.moleculeLists);
const selectedDatasetCompounds = useSelector(state => state.datasetsReducers.compoundsToBuyDatasetMap);
const datasetVisibleDatasetCompoundsList = useSelector(state => state.datasetsReducers.ligandLists);
Expand Down Expand Up @@ -226,31 +230,27 @@ const JobConfigurationDialog = ({ snapshots }) => {
dispatch(setDisableRedirect(true));
dispatch(setDontShowShareSnapshot(true));

// With the above flags set, createNewSnapshot returns the ID of newly created snapshot as the second item in the array
const snapshotId = (
await dispatch(
createNewSnapshot({
title,
description,
type,
author,
parent,
session_project,
nglViewList,
stage,
overwriteSnapshot: false,
createDiscourse: true
})
)
)[1];

// Create new snapshot
const newSnapshot = await dispatch(getSnapshotAttributesByID(snapshotId));

// Trigger graph rerender
dispatch(refreshJobsData());

return newSnapshot;
return dispatch(
createNewSnapshot({
title,
description,
type,
author,
parent,
session_project,
nglViewList,
stage,
overwriteSnapshot: false,
createDiscourse: true
})
)
.then(snapshotId => {
return dispatch(getSnapshotAttributesByID(snapshotId));
})
.then(snapshot => {
dispatch(refreshJobsData());
return snapshot;
});
};

const validate = values => {
Expand All @@ -265,6 +265,7 @@ const JobConfigurationDialog = ({ snapshots }) => {

const onSubmitForm = async ({ job, inputs, snapshot }) => {
try {
setIsLaunchButtonDisabled(true);
let chosenLHSCompounds = null;
// TODO: chosenRHSCompounds
let chosenRHSCompounds = null;
Expand All @@ -274,9 +275,10 @@ const JobConfigurationDialog = ({ snapshots }) => {
chosenSnapshot = snapshot;
if (!snapshot.additional_info) {
chosenSnapshot = await createSnapshot();
const currentSnapshotSelectedCompounds = getAllMolecules
dispatch(changeSnapshot(currentSessionProject.projectID, chosenSnapshot.id, stage, true));
const currentSnapshotSelectedCompounds = allMolecules
.filter(molecule => currentSnapshotSelectedCompoundsIDs.includes(molecule.id))
.map(molecule => molecule.code);
.map(molecule => molecule /*.code*/);

const currentSnapshotSelectedDatasetsCompounds = [];
Object.keys(selectedDatasetCompounds).map(datasetName => {
Expand All @@ -290,7 +292,9 @@ const JobConfigurationDialog = ({ snapshots }) => {
chosenLHSCompounds = currentSnapshotSelectedCompounds;
chosenRHSCompounds = currentSnapshotSelectedDatasetsCompounds;
} else {
chosenLHSCompounds = snapshot.additional_info.currentSnapshotSelectedCompounds;
chosenLHSCompounds = allMolecules.filter(m =>
snapshot.additional_info.currentSnapshotSelectedCompounds.includes(m.code)
);
}
const savedSelection = [];
Object.keys(chosenSnapshot.additional_info.currentSnapshotSelectedDatasetsCompounds).map(datasetName => {
Expand All @@ -300,9 +304,9 @@ const JobConfigurationDialog = ({ snapshots }) => {
});
chosenRHSCompounds = savedSelection;
} else if (inputs === 'selected-inputs') {
const currentSnapshotSelectedCompounds = getAllMolecules
const currentSnapshotSelectedCompounds = allMolecules
.filter(molecule => currentSnapshotSelectedCompoundsIDs.includes(molecule.id))
.map(molecule => molecule.code);
.map(molecule => molecule /*.code*/);

const currentSnapshotSelectedDatasetsCompounds = [];
Object.keys(selectedDatasetCompounds).map(datasetName => {
Expand All @@ -325,27 +329,30 @@ const JobConfigurationDialog = ({ snapshots }) => {

console.log('onSubmitForm checkpoint');

const currentSnapshotSavedSelectedLHSObs = allMolecules.filter(m =>
currentSnapshot.additional_info.currentSnapshotSelectedCompounds.includes(m.code)
);
// In case the selection is different from the one saved with the snapshot, create a new snapshot with the current selection
if (
!currentSnapshot.additional_info ||
!areArraysSame(
currentSnapshot.additional_info.currentSnapshotSelectedCompounds,
currentSnapshotSelectedCompounds
) ||
!areArraysSame(savedSelection, currentSnapshotSelectedDatasetsCompounds)
!areArraysSame(currentSnapshotSavedSelectedLHSObs, currentSnapshotSelectedCompounds)
// || !areArraysSame(savedSelection, currentSnapshotSelectedDatasetsCompounds)
) {
chosenSnapshot = await createSnapshot();
dispatch(changeSnapshot(currentSessionProject.projectID, chosenSnapshot.id, stage, true));
chosenLHSCompounds = currentSnapshotSelectedCompounds;
chosenRHSCompounds = currentSnapshotSelectedDatasetsCompounds;
} else {
chosenSnapshot = currentSnapshot;
chosenLHSCompounds = currentSnapshot.additional_info.currentSnapshotSelectedCompounds;
chosenLHSCompounds = currentSnapshotSelectedCompounds; //allMolecules.filter(
// m => m.code === currentSnapshot.additional_info.currentSnapshotSelectedCompounds
// );
chosenRHSCompounds = savedSelection;
}
} else if (inputs === 'visible-inputs') {
const currentSnapshotVisibleCompounds = getAllMolecules
const currentSnapshotVisibleCompounds = allMolecules
.filter(molecule => currentSnapshotVisibleCompoundsIDs.includes(molecule.id))
.map(molecule => molecule.code);
.map(molecule => molecule /*.code*/);

const currentSnapshotVisibleDatasetCompounds = [];
Object.keys(datasetVisibleDatasetCompoundsList).map(datasetName => {
Expand All @@ -369,30 +376,33 @@ const JobConfigurationDialog = ({ snapshots }) => {
console.log('onSubmitForm checkpoint');

// In case the visible mols are different from the ones saved with the snapshot, create a new snapshot with the current visible mols
const currentSnapshotSavedSelectedLHSObs = allMolecules.filter(m =>
currentSnapshot.additional_info.currentSnapshotVisibleCompounds.includes(m.code)
);
if (
!currentSnapshot.additional_info ||
!areArraysSame(
currentSnapshot.additional_info.currentSnapshotVisibleCompounds,
currentSnapshotVisibleCompounds
) ||
!areArraysSame(currentSnapshotSavedSelectedLHSObs, currentSnapshotVisibleCompounds) ||
!areArraysSame(savedVisibleCompounds, currentSnapshotVisibleDatasetCompounds)
) {
chosenSnapshot = await createSnapshot();
dispatch(changeSnapshot(currentSessionProject.projectID, chosenSnapshot.id, stage, true));
chosenLHSCompounds = currentSnapshotVisibleCompounds;
chosenRHSCompounds = currentSnapshotVisibleDatasetCompounds;
} else {
chosenSnapshot = currentSnapshot;
chosenLHSCompounds = currentSnapshot.additional_info.currentSnapshotVisibleCompounds;
chosenLHSCompounds = currentSnapshotVisibleCompounds; //allMolecules.filter(
// m => m.code === currentSnapshot.additional_info.currentSnapshotSelectedCompounds
// );
chosenRHSCompounds = savedVisibleCompounds;
}
}

//reconstruct lhs molecules
const chosenLHSCompoundsFull = chosenLHSCompounds.map(molecule => {
return getAllMolecules.find(mol => mol.code === molecule);
});
// const chosenLHSCompoundsFull = chosenLHSCompounds.map(molecule => {
// return allMolecules.find(mol => mol.code === molecule);
// });
// Remove the unnecessary part from protein_code
chosenLHSCompounds = chosenLHSCompounds.map(molecule => getMoleculeTitle(molecule));
// chosenLHSCompounds = chosenLHSCompounds.map(molecule => getMoleculeTitle(molecule));

if (chosenLHSCompounds.length > 0) {
// Close the actual pop up window
Expand All @@ -408,8 +418,8 @@ const JobConfigurationDialog = ({ snapshots }) => {
session_project: currentSessionProject.projectID,
target: targetId,
squonk_project: dispatch(getSquonkProject()),
proteins: chosenLHSCompounds.join(),
compounds: chosenRHSCompounds.join()
proteins: chosenLHSCompounds.map(m => extractRelativePath(m.apo_desolv_file, base_data_url)).join(),
compounds: chosenLHSCompounds.map(m => extractRelativePath(m.ligand_mol, base_data_url)).join()
});

let transfer_root = null;
Expand All @@ -426,11 +436,11 @@ const JobConfigurationDialog = ({ snapshots }) => {
snapshot: chosenSnapshot,
// transfer_root: transfer_root,
// transfer_target: transfer_target,
inputs_dir: `${transfer_root}/${transfer_target}`,
inputs_dir: `${transfer_root}`,
// Prepares data for expanding, see comments in JobFragmentProteinSelectWindow
data: {
// lhs: chosenLHSCompounds.map(compound => getMoleculeEnumName(compound))
lhs: chosenLHSCompoundsFull
lhs: chosenLHSCompounds
}
})
);
Expand All @@ -443,7 +453,9 @@ const JobConfigurationDialog = ({ snapshots }) => {
setErrorMsg("There's no selected inputs to run the job.");
setIsError(true);
}
setIsLaunchButtonDisabled(false);
} catch (err) {
setIsLaunchButtonDisabled(false);
console.error(err);
setErrorMsg(err.response.data);
setIsError(true);
Expand Down Expand Up @@ -574,7 +586,7 @@ const JobConfigurationDialog = ({ snapshots }) => {
{errorMsg?.message ?? errorMsg}
</Paper>
)}
<Button color="primary" size="large" type="submit">
<Button color="primary" size="large" type="submit" disabled={isLaunchButtonDisabled}>
Launch
</Button>
</div>
Expand Down
3 changes: 2 additions & 1 deletion js/components/preview/projectHistoryPanel/useJobSchema.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const prepareItem = (item, config, targetName) => {

if (config?.file) {
const file = item[config.file];
itemPath = file;
itemPath = file.split('/').pop();
itemName = getMoleculeEnumName(item.code, targetName);

if (config?.skip && config?.skip > 0) {
Expand Down Expand Up @@ -163,6 +163,7 @@ export const useJobSchema = jobLauncherData => {
...options.properties,
...outputs.properties
}).map(([key, property]) => {
console.log(`Processing property ${key} - ${JSON.stringify(property)}`);
return [key, compileProperty(property, data, ignoreFirstRound, targetName)];
})
)
Expand Down
6 changes: 5 additions & 1 deletion js/components/preview/projectHistoryPanel/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,9 @@ import { api } from '../../../utils/api';
import { base_url } from '../../routes/constants';

export const isSquonkProjectAccessible = async jobId => {
return api({ url: `${base_url}/viewer/job_access/?job_request_id=${jobId}` });
return api({ url: `${base_url}/api/job_access/?job_request_id=${jobId}` });
};

export const extractRelativePath = (path, parentPath) => {
return path.replace(parentPath, '');
};
42 changes: 25 additions & 17 deletions js/components/projects/redux/dispatchActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,8 @@ export const getSnapshotAttributesByID = snapshotID => (dispatch, getState) => {
currentSnapshotList = {};
}
const snapshot = parseSnapshotAttributes(response.data);
currentSnapshotList[snapshotID] = snapshot;
currentSnapshotList = { ...currentSnapshotList, [`${snapshotID}`]: snapshot };
// currentSnapshotList[`${snapshotID}`] = snapshot;
dispatch(setCurrentSnapshotList(currentSnapshotList));

if (response.data.children && response.data.children.length > 0) {
Expand Down Expand Up @@ -461,18 +462,20 @@ export const getJobConfigurationsFromServer = () => async (dispatch, getState) =
for (let i = 0; i < availableJobs.length; i++) {
const job = availableJobs[i];
let jobConfig = await getJobConfigFromServer(job.job_collection, job.job_name, job.job_version);
jobConfig = preprocessJobConfig(jobConfig);
// console.log(JSON.stringify(filteredJobConfig));
const jobOject = {
id: jobConfig.id,
name: jobConfig.collection,
description: jobConfig.description,
slug: jobConfig.job,
spec: jobConfig,
overrides: overrides,
overrideIndex: job.index
};
result.push(jobOject);
if (jobConfig) {
jobConfig = preprocessJobConfig(jobConfig);
// console.log(JSON.stringify(filteredJobConfig));
const jobOject = {
id: jobConfig.id,
name: jobConfig.collection,
description: jobConfig.description,
slug: jobConfig.job,
spec: jobConfig,
overrides: overrides,
overrideIndex: job.index
};
result.push(jobOject);
}
}

return result;
Expand All @@ -497,11 +500,16 @@ const removePropDeep = (obj, propName) => {
};

const getJobConfigFromServer = async (job_collection, job_name, job_version) => {
const resultCall = await api({
url: `${base_url}/api/job_config/?job_name=${job_name.trim()}&job_version=${job_version.trim()}&job_collection=${job_collection.trim()}`
});
let resultCall = null;
try {
resultCall = await api({
url: `${base_url}/api/job_config/?job_name=${job_name.trim()}&job_version=${job_version.trim()}&job_collection=${job_collection.trim()}`
});
} catch (e) {
console.log(`Job configuration for ${job_collection} ${job_name} ${job_version} not found`);
}

return resultCall.data;
return resultCall?.data;
};

const getJobOverrides = async () => {
Expand Down
2 changes: 2 additions & 0 deletions js/components/routes/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,5 @@ export const base_url = window.location.protocol + '//' + window.location.host;
//export const base_url = 'https://fragalysis-boris-default.xchem-dev.diamond.ac.uk'; //url for debugging on secondary dev pod
// export const base_url = 'https://fragalysis.xchem.diamond.ac.uk'; //url for debugging staging
// export const base_url = 'https://fragalysis.diamond.ac.uk'; //url for debugging production

export const base_data_url = base_url + '/media/';
Loading

0 comments on commit 9393305

Please sign in to comment.