Exemplo n.º 1
0
    def _path_to_pipe(self, dataset_path):
        """ FIXME TODO this needs to be simplified """
        class context:
            path = dataset_path.resolve()
            id = path.id
            uri_api = path.as_uri()
            uri_human = path.as_uri()

        class lifters:
            # minimal set
            id = context.id
            folder_name = context.path.name
            uri_api = context.uri_api
            uri_human = context.uri_human
            timestamp_export_start = None

            # extended requirements (annoying)
            # FIXME these need to be removed
            techniques = 'FAKE TECHNIQUE'
            award_manual = 'FAKE TOTALLY NOT AN AWARD'
            modality = 'THE MODALITY THE HAS BECOME ONE WITH NOTHINGNESS'
            organ_term = 'ilxtr:NOGGIN'  # expects a curie or iri
            protocol_uris = ('https://example.org/TOTALLY-NOT-A-REAL-URI', )
            affiliations = lambda _: None

        pipe = pipes.PipelineEnd(dataset_path, lifters, context)
        return pipe
Exemplo n.º 2
0
    def pipeline(self, timestamp):
        if hasattr(self, '_pipeline'):
            return self._pipeline

        datasetdata = self.datasetdata
        dsc = datasetdata.cache.dataset
        if dsc is None:
            raise exc.NotInDatasetError

        #dataset = dat.DatasetStructure(dsc)  # FIXME should be able to go back

        class ProtocolHelper(ProtocolData):  # FIXME so ... bad ...
            @property
            def protocol_uris(self,
                              outer_self=self
                              ):  # FIXME this needs to be pipelined
                try:
                    yield from adops.get(outer_self.data(),
                                         ['meta', 'protocol_url_or_doi'])
                except exc.NoSourcePathError:
                    pass

        ph = ProtocolHelper()

        # FIXME except for the adds, everything here should be a pipeline
        class Lifters:  # do this to prevent accidental data leaks
            # context
            id = dsc.id  # in case we are somewhere else
            timestamp_export_start = timestamp
            #folder_name = dsc.name
            #uri_api = dsc.uri_api
            #uri_human = dsc.uri_human

            # protocols
            protocol = ph.protocol
            #protcur = self.protcur

            # aux
            organ = self.organ
            member = self.member
            affiliations = self.affiliations

            # hypothesis that the calling of methods was the issue
            # also fails
            _organs_sheet = self.organs_sheet
            #modality = self.organs_sheet.modality(id)
            #award_manual = self.organs_sheet.award_manual(id)
            #techniques = self.organs_sheet.techniques(id)
            #protocol_uris = self.organs_sheet.protocol_uris(id)
            @property
            def modality(self):
                return self._organs_sheet.modality(self.id)

            @property
            def award_manual(self):
                return self._organs_sheet.award_manual(self.id)

            @property
            def techniques(self):
                return self._organs_sheet.techniques(self.id)

            @property
            def protocol_uris(self):
                return self._organs_sheet.protocol_uris(self.id)

            #sheets
            #organ_term = self.organs_sheet.organ_term(id)
            @property
            def organ_term(self):
                return self._organs_sheet.organ_term(self.id)

        class RuntimeContext:
            """ utility for logging etc. """
            id = dsc.id  # TODO can we eliminate the need for lifters this way?
            uri_api = dsc.uri_api  # FIXME black blackfynn ids their own thing
            uri_human = dsc.uri_human  # so uri_api and uri_human can be computed from them ...
            path = self.path

        lifters = Lifters()
        # helper key was bad because it means that pipelines have to
        # know the structure of their helper pipelines and maintain them
        # across changes, better to use the lifters as other pipelines that
        # can start from a single piece of data and return a formatted result
        # and track their own provenance, the concept of a helper that holds
        # all the prior existing data is not a bad one, it just just that it
        # is better to create objects that can take the information already
        # in the data for the current pipeline and return an expanded verion
        self._pipeline = pipes.PipelineEnd(self.path, lifters,
                                           RuntimeContext())
        return self._pipeline