Trying hard to figure out why the DCOS servers think the protocol builder is enabled.

This commit is contained in:
Dan Funk 2020-05-26 23:18:14 -04:00
parent 7869fa596e
commit 0025931a2e

View File

@ -216,34 +216,36 @@ class StudyService(object):
"""Assures that the studies we have locally for the given user are """Assures that the studies we have locally for the given user are
in sync with the studies available in protocol builder. """ in sync with the studies available in protocol builder. """
if not ProtocolBuilderService.is_enabled(): if ProtocolBuilderService.is_enabled():
return
# Get studies matching this user from Protocol Builder app.logger.info("The Protocol Builder is enabled. app.config['PB_ENABLED'] = " +
pb_studies: List[ProtocolBuilderStudy] = ProtocolBuilderService.get_studies(user.uid) str(app.config['PB_ENABLED']))
# Get studies from the database # Get studies matching this user from Protocol Builder
db_studies = session.query(StudyModel).filter_by(user_uid=user.uid).all() pb_studies: List[ProtocolBuilderStudy] = ProtocolBuilderService.get_studies(user.uid)
# Update all studies from the protocol builder, create new studies as needed. # Get studies from the database
# Futher assures that every active study (that does exist in the protocol builder) db_studies = session.query(StudyModel).filter_by(user_uid=user.uid).all()
# has a reference to every available workflow (though some may not have started yet)
for pb_study in pb_studies:
db_study = next((s for s in db_studies if s.id == pb_study.STUDYID), None)
if not db_study:
db_study = StudyModel(id=pb_study.STUDYID)
session.add(db_study)
db_studies.append(db_study)
db_study.update_from_protocol_builder(pb_study)
StudyService._add_all_workflow_specs_to_study(db_study)
# Mark studies as inactive that are no longer in Protocol Builder # Update all studies from the protocol builder, create new studies as needed.
for study in db_studies: # Futher assures that every active study (that does exist in the protocol builder)
pb_study = next((pbs for pbs in pb_studies if pbs.STUDYID == study.id), None) # has a reference to every available workflow (though some may not have started yet)
if not pb_study: for pb_study in pb_studies:
study.protocol_builder_status = ProtocolBuilderStatus.ABANDONED db_study = next((s for s in db_studies if s.id == pb_study.STUDYID), None)
if not db_study:
db_study = StudyModel(id=pb_study.STUDYID)
session.add(db_study)
db_studies.append(db_study)
db_study.update_from_protocol_builder(pb_study)
StudyService._add_all_workflow_specs_to_study(db_study)
db.session.commit() # Mark studies as inactive that are no longer in Protocol Builder
for study in db_studies:
pb_study = next((pbs for pbs in pb_studies if pbs.STUDYID == study.id), None)
if not pb_study:
study.protocol_builder_status = ProtocolBuilderStatus.ABANDONED
db.session.commit()
@staticmethod @staticmethod
def __update_status_of_workflow_meta(workflow_metas, status): def __update_status_of_workflow_meta(workflow_metas, status):