Ejemplo n.º 1
0
 def strip_config(c):
     c_prefix = serialize_config(
         common_data.get("configurations_prefix",
                         'placeholder-placeholder'))
     c_suffix = serialize_config(
         common_data.get("configurations_suffix",
                         'placeholder-placeholder'))
     return c.replace(c_prefix, '').replace(c_suffix, '')
Ejemplo n.º 2
0
def downgrade():
    start = time.time()
    print('Downgrading extra_parameters')
    op.alter_column('outputs',
                    'extra_parameters',
                    type_=sa.dialects.postgresql.JSON,
                    postgresql_using='extra_parameters::jsonb::text')

    print(f'Removing idx_outputs_filter [{time.time() - start:.1f}s]')
    op.drop_index('idx_outputs_filter')

    print(f'Downgrading configuration [{time.time() - start:.1f}s]')
    op.add_column('outputs', sa.Column('configuration', sa.STRING))
    bind = op.get_bind()
    session = Session(bind=bind)
    for idx, o in enumerate(session.query(Output)):
        if idx % 100 == 0:
            print(f"#{idx} [{time.time() - start}s]")
            session.commit()
        o.configuration = serialize_config(o.configurations)
        session.add(o)

    session.flush()
    session.commit()
    op.drop_column("batches", "configurations")
Ejemplo n.º 3
0
 def test_serialize_config(self):
     from qaboard.conventions import serialize_config
     self.assertEqual(serialize_config(['a', 'b', 'c']), 'a:b:c')
     self.assertEqual(serialize_config(['a', {'b': 1}]), 'a:{"b": 1}')
     self.assertEqual(serialize_config(['a', '{"b":1']), 'a:{"b":1')
Ejemplo n.º 4
0
 def configuration(self):
     return serialize_config(self.configurations)