GSTT-CSC / MLOps

Framework for building ML apps
GNU General Public License v3.0
9 stars 5 forks source link

validate_data feature for LoadImageXNATd can only handle a single action #83

Closed laurencejackson closed 1 year ago

laurencejackson commented 2 years ago
                for action, data_label in self.actions:

                    logger.debug(f"Running XNAT action: {action}")

                    with xnat.connect(server=self.xnat_configuration['server'],
                                      user=self.xnat_configuration['user'],
                                      password=self.xnat_configuration['password'],
                                      verify=self.xnat_configuration['verify'],
                                      ) as session:

                        # "connect session to subject uri"
                        subject_obj = session.create_object(d['subject_uri'])
                        logger.debug(f"Found XNAT subject: {subject_obj}")

                        # perform action on subject object
                        try:
                            xnat_obj = action(subject_obj)
                            logger.debug(f"Running {action} found XNAT obj: {xnat_obj}")
                        except TypeError:
                            logger.warn(f'No suitable data found for action {action} and subject {d["subject_uri"]}')
                            xnat_obj = None

                        if self.validate_data:
                            if xnat_obj is not None:
                                d[data_label] = True
                                return d
                            else:
                                d[data_label] = False
                                return d

is this code block the data dictionary d is returned inside the action loop. This means that if we pass multiple actions to validate data only the first will be processed.

laurencejackson commented 1 year ago

resolved in previous PR