Exemplo n.º 1
0
    def wipe_asset(self, asset_key):
        check.inst_param(asset_key, "asset_key", AssetKey)

        wipe_timestamp = pendulum.now("UTC").timestamp()

        if self.has_secondary_index(ASSET_KEY_INDEX_COLS):
            with self.index_connection() as conn:
                conn.execute(
                    AssetKeyTable.update()  # pylint: disable=no-value-for-parameter
                    .where(
                        db.or_(
                            AssetKeyTable.c.asset_key == asset_key.to_string(),
                            AssetKeyTable.c.asset_key == asset_key.to_string(
                                legacy=True),
                        )).values(
                            last_materialization=None,
                            last_run_id=None,
                            last_materialization_timestamp=None,
                            tags=None,
                            asset_details=serialize_dagster_namedtuple(
                                AssetDetails(
                                    last_wipe_timestamp=wipe_timestamp)),
                            wipe_timestamp=utc_datetime_from_timestamp(
                                wipe_timestamp),
                        ))

        else:
            with self.index_connection() as conn:
                conn.execute(
                    AssetKeyTable.update()  # pylint: disable=no-value-for-parameter
                    .where(
                        db.or_(
                            AssetKeyTable.c.asset_key == asset_key.to_string(),
                            AssetKeyTable.c.asset_key == asset_key.to_string(
                                legacy=True),
                        )).values(
                            last_materialization=None,
                            last_run_id=None,
                            asset_details=serialize_dagster_namedtuple(
                                AssetDetails(
                                    last_wipe_timestamp=wipe_timestamp)),
                        ))
Exemplo n.º 2
0
    def wipe_asset(self, asset_key):
        check.inst_param(asset_key, "asset_key", AssetKey)

        with self.index_connection() as conn:
            conn.execute(
                AssetKeyTable.update()  # pylint: disable=no-value-for-parameter
                .where(
                    db.or_(
                        AssetKeyTable.c.asset_key == asset_key.to_string(),
                        AssetKeyTable.c.asset_key == asset_key.to_string(
                            legacy=True),
                    )).values(asset_details=serialize_dagster_namedtuple(
                        AssetDetails(last_wipe_timestamp=pendulum.now(
                            "UTC").timestamp()))))
Exemplo n.º 3
0
 def get_asset_records(
     self,
     asset_keys: Optional[Sequence[AssetKey]] = None
 ) -> Iterable[AssetRecord]:
     records = []
     for asset_key, asset in self._assets.items():
         if not asset_keys or asset_key in asset_keys:
             wipe_timestamp = self._wiped_asset_keys.get(asset_key)
             if (not wipe_timestamp or wipe_timestamp < asset.get(
                     "last_materialization_timestamp").timestamp()):
                 records.append(
                     AssetRecord(
                         storage_id=asset["id"],
                         asset_entry=AssetEntry(
                             asset_key=asset_key,
                             last_materialization=asset.get(
                                 "last_materialization"),
                             last_run_id=asset.get("last_run_id"),
                             asset_details=AssetDetails(
                                 last_wipe_timestamp=wipe_timestamp)
                             if wipe_timestamp else None,
                         ),
                     ))
     return records