Example #1
0
    def test_infer_status(self):
        obs = infer_status([])
        self.assertEqual(obs, 'sandbox')

        obs = infer_status([['private']])
        self.assertEqual(obs, 'private')

        obs = infer_status([['private'], ['public']])
        self.assertEqual(obs, 'public')

        obs = infer_status([['sandbox'], ['awaiting_approval']])
        self.assertEqual(obs, 'awaiting_approval')

        obs = infer_status([['sandbox'], ['sandbox']])
        self.assertEqual(obs, 'sandbox')
Example #2
0
    def test_infer_status(self):
        obs = infer_status([])
        self.assertEqual(obs, "sandbox")

        obs = infer_status([["private"]])
        self.assertEqual(obs, "private")

        obs = infer_status([["private"], ["public"]])
        self.assertEqual(obs, "public")

        obs = infer_status([["sandbox"], ["awaiting_approval"]])
        self.assertEqual(obs, "awaiting_approval")

        obs = infer_status([["sandbox"], ["sandbox"]])
        self.assertEqual(obs, "sandbox")
Example #3
0
    def status(self):
        """The status of the prep template

        Returns
        -------
        str
            The status of the prep template

        Notes
        -----
        The status of a prep template is inferred by the status of the
        processed data generated from this prep template. If no processed
        data has been generated with this prep template; then the status
        is 'sandbox'.
        """
        conn_handler = SQLConnectionHandler()
        sql = """SELECT processed_data_status
                FROM qiita.processed_data_status pds
                  JOIN qiita.processed_data pd
                    USING (processed_data_status_id)
                  JOIN qiita.preprocessed_processed_data ppd_pd
                    USING (processed_data_id)
                  JOIN qiita.prep_template_preprocessed_data pt_ppd
                    USING (preprocessed_data_id)
                WHERE pt_ppd.prep_template_id=%s"""
        pd_statuses = conn_handler.execute_fetchall(sql, (self._id,))

        return infer_status(pd_statuses)
Example #4
0
    def status(self):
        """The status of the prep template

        Returns
        -------
        str
            The status of the prep template

        Notes
        -----
        The status of a prep template is inferred by the status of the
        processed data generated from this prep template. If no processed
        data has been generated with this prep template; then the status
        is 'sandbox'.
        """
        with TRN:
            sql = """SELECT processed_data_status
                    FROM qiita.processed_data_status pds
                      JOIN qiita.processed_data pd
                        USING (processed_data_status_id)
                      JOIN qiita.preprocessed_processed_data ppd_pd
                        USING (processed_data_id)
                      JOIN qiita.prep_template_preprocessed_data pt_ppd
                        USING (preprocessed_data_id)
                    WHERE pt_ppd.prep_template_id=%s"""
            TRN.add(sql, [self._id])

            return infer_status(TRN.execute_fetchindex())
def _propagate_visibility(artifact):
    """Propagates the visibility of an artifact to all its ancestors

    Parameters
    ----------
    artifact : qiita_db.artifact.Artifact
        The artifact to propagate the visibility for

    Notes
    -----
    This is emulating the previous functionality, in which the status of the
    processed data was propagated to the preprocessed/raw data that was used
    to generate such processed data. In the current interface, only the status
    of the BIOM artifacts (processed data) can be changed, so this works as
    expected.
    """
    for a in artifact.ancestors.nodes():
        visibilities = [[c.visibility] for c in a.descendants.nodes()
                        if c.artifact_type == 'BIOM']
        a.visibility = infer_status(visibilities)