def wipe_asset(self, asset_key): check.inst_param(asset_key, "asset_key", AssetKey) event_query = db.select([ SqlEventLogStorageTable.c.id, SqlEventLogStorageTable.c.event ]).where( db.or_( SqlEventLogStorageTable.c.asset_key == asset_key.to_string(), SqlEventLogStorageTable.c.asset_key == asset_key.to_string( legacy=True), )) asset_key_delete = AssetKeyTable.delete().where( # pylint: disable=no-value-for-parameter db.or_( AssetKeyTable.c.asset_key == asset_key.to_string(), AssetKeyTable.c.asset_key == asset_key.to_string(legacy=True), )) with self.connect() as conn: conn.execute(asset_key_delete) results = conn.execute(event_query).fetchall() for row_id, json_str in results: try: event_record = deserialize_json_to_dagster_namedtuple(json_str) if not isinstance(event_record, EventRecord): continue assert event_record.dagster_event.event_specific_data.materialization.asset_key dagster_event = event_record.dagster_event event_specific_data = dagster_event.event_specific_data materialization = event_specific_data.materialization updated_materialization = Materialization( label=materialization.label, description=materialization.description, metadata_entries=materialization.metadata_entries, asset_key=None, skip_deprecation_warning=True, ) updated_event_specific_data = event_specific_data._replace( materialization=updated_materialization) updated_dagster_event = dagster_event._replace( event_specific_data=updated_event_specific_data) updated_record = event_record._replace( dagster_event=updated_dagster_event) # update the event_record here self.update_event_log_record(row_id, updated_record) except seven.JSONDecodeError: logging.warning( "Could not parse asset event record id `{}`.".format( row_id))
def _remove_asset_key_from_event_record(self, event_record): if not event_record.dagster_event.event_specific_data.materialization.asset_key: return event_record dagster_event = event_record.dagster_event event_specific_data = dagster_event.event_specific_data materialization = event_specific_data.materialization updated_materialization = Materialization( label=materialization.label, description=materialization.description, metadata_entries=materialization.metadata_entries, asset_key=None, skip_deprecation_warning=True, ) updated_event_specific_data = event_specific_data._replace( materialization=updated_materialization) updated_dagster_event = dagster_event._replace( event_specific_data=updated_event_specific_data) return event_record._replace(dagster_event=updated_dagster_event)