Esempio n. 1
0
def update_properties(db: PartitionedDatabase, model_id_or_name: str,
                      body: List[JsonDict]):
    x_bf_trace_id = AuditLogger.trace_id_header()
    payload: List[ModelProperty] = ModelProperty.schema().load(body, many=True)
    with db.transaction() as tx:
        model = db.get_model_tx(tx, model_id_or_name)

        properties = db.update_properties_tx(tx, model, *payload)

        PennsieveJobsClient.get().send_changelog_events(
            organization_id=db.organization_id,
            dataset_id=db.dataset_id,
            user_id=db.user_id,
            events=[
                CreateModelProperty(property_name=p.name,
                                    model_id=UUID(model.id),
                                    model_name=model.name)
                if created else UpdateModelProperty(property_name=p.name,
                                                    model_id=UUID(model.id),
                                                    model_name=model.name)
                for p, created in properties
            ],
            trace_id=TraceId(x_bf_trace_id),
        )
        return [p.to_dict() for p, _ in properties]
Esempio n. 2
0
def test_convert_properties(properties):
    schema = ModelProperty.schema()
    schema.dumps(properties[0])