示例#1
0
    def test_parse(self):
        tokenized_query = ExperimentQueryManager.tokenize(self.query1)
        parsed_query = ExperimentQueryManager.parse(tokenized_query)
        assert parsed_query == {
            'updated_at':
            [QueryOpSpec(op='<=', negation=False, params='2020-10-10')],
            'started_at': [
                QueryOpSpec(op='>', negation=False, params='2010-10-10'),
                QueryOpSpec(op='=', negation=True, params='2016-10-01')
            ],
        }

        tokenized_query = ExperimentQueryManager.tokenize(self.query2)
        parsed_query = ExperimentQueryManager.parse(tokenized_query)
        assert parsed_query == {
            'metric__loss': [QueryOpSpec('<=', False, params=0.8)],
            'status':
            [QueryOpSpec('|', False, params=['starting', 'running'])],
        }

        tokenized_query = ExperimentQueryManager.tokenize(self.query3)
        parsed_query = ExperimentQueryManager.parse(tokenized_query)
        assert parsed_query == {
            'finished_at':
            [QueryOpSpec('..', False, params=['2012-12-12', '2042-12-12'])],
        }

        tokenized_query = ExperimentQueryManager.tokenize(self.query4)
        parsed_query = ExperimentQueryManager.parse(tokenized_query)
        assert parsed_query == {
            'tags': [
                QueryOpSpec('|', True, params=['tag1', 'tag2']),
                QueryOpSpec('=', False, params='tag3')
            ],
        }
示例#2
0
    def test_build(self):
        tokenized_query = ExperimentQueryManager.tokenize(self.query1)
        parsed_query = ExperimentQueryManager.parse(tokenized_query)
        built_query = ExperimentQueryManager.build(parsed_query)
        assert built_query == {
            'updated_at': [
                QueryCondSpec(DateTimeCondition(op='<=', negation=False),
                              params='2020-10-10')
            ],
            'started_at': [
                QueryCondSpec(DateTimeCondition(op='>', negation=False),
                              params='2010-10-10'),
                QueryCondSpec(DateTimeCondition(op='=', negation=True),
                              params='2016-10-01')
            ],
        }

        tokenized_query = ExperimentQueryManager.tokenize(self.query2)
        parsed_query = ExperimentQueryManager.parse(tokenized_query)
        built_query = ExperimentQueryManager.build(parsed_query)
        assert built_query == {
            'metric__loss': [
                QueryCondSpec(ComparisonCondition(op='<=', negation=False),
                              params=0.8)
            ],
            'status': [
                QueryCondSpec(ValueCondition(op='|', negation=False),
                              params=['starting', 'running'])
            ],
        }

        tokenized_query = ExperimentQueryManager.tokenize(self.query3)
        parsed_query = ExperimentQueryManager.parse(tokenized_query)
        built_query = ExperimentQueryManager.build(parsed_query)
        assert built_query == {
            'finished_at': [
                QueryCondSpec(DateTimeCondition(op='..', negation=False),
                              params=['2012-12-12', '2042-12-12'])
            ],
        }

        tokenized_query = ExperimentQueryManager.tokenize(self.query4)
        parsed_query = ExperimentQueryManager.parse(tokenized_query)
        built_query = ExperimentQueryManager.build(parsed_query)
        assert built_query == {
            'tags': [
                QueryCondSpec(ArrayCondition(op='|', negation=True),
                              params=['tag1', 'tag2']),
                QueryCondSpec(ArrayCondition(op='=', negation=False),
                              params='tag3')
            ],
        }
示例#3
0
 def test_handle(self):
     tokenized_query = ExperimentQueryManager.tokenize(self.query1)
     parsed_query = ExperimentQueryManager.parse(tokenized_query)
     built_query = ExperimentQueryManager.build(parsed_query)
     assert built_query == ExperimentQueryManager.handle_query(self.query1)