flowchart TD
A{"new file
sensor"}
B["source table asset
(load with xml2db)"]
C{"asset sensor"}
D["final table asset
(transform with DBT)"]
A --> B --> C --> D
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sqlalchemy import Table, Column, Index, Integer, VARCHAR, MetaData, ForeignKey | |
from sqlalchemy.dialects import mssql | |
from sqlalchemy.schema import CreateTable, CreateIndex | |
md = MetaData() | |
trade = Table( | |
"trade", | |
md, | |
Column("pk_trade", Integer, primary_key=True, autoincrement=True), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logging | |
from datetime import datetime | |
from typing import Union | |
def get_configured_logger(level: Union[int, str]) -> logging.Logger: | |
""" | |
Set a useful logging format and return a logger with a full reference to the current module. | |
>>> import logging |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import zipfile | |
from typing import Dict, Union, IO | |
from io import BytesIO | |
from zipfile import ZipFile | |
def unzip_recursively(archive_path: Union[str, IO[bytes]]) -> Dict[str, BytesIO]: | |
""" | |
Unzip archive recursively |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git submodule sync && git submodule update --init --force --recursive |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from dagster import ( | |
RunRequest, | |
MultiAssetSensorEvaluationContext, | |
multi_asset_sensor, | |
AssetSelection, | |
SkipReason, | |
RunsFilter, | |
DagsterRunStatus, | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from xml2db import DataModel | |
# Create a data model of tables with relations based on the XSD file | |
data_model = DataModel( | |
xsd_file="path/to/file.xsd", | |
connection_string="mssql+pyodbc://server/database?driver=ODBC+Driver+17+for+SQL+Server&trusted_connection=yes", | |
) | |
# Parse an XML file based on this XSD | |
document = data_model.parse_xml( | |
xml_file="path/to/file.xml" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DAILY_PARTITIONS = DailyPartitionsDefinition(start_date="2022-06-01") | |
@asset( | |
description="Files to load", | |
partitions_def=DAILY_PARTITIONS, | |
key_prefix="source", | |
config_schema={ | |
"selected_file_paths": Field(Array(str), is_required=False, default_value=[]) | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import datetime | |
from dagster import ( | |
sensor, | |
SensorDefinition, | |
AssetKey, | |
SkipReason, | |
RunsFilter, | |
DagsterRunStatus, | |
SensorEvaluationContext, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from dagster import ( | |
RunRequest, | |
MultiAssetSensorEvaluationContext, | |
multi_asset_sensor, | |
AssetSelection, | |
SkipReason, | |
RunsFilter, | |
DagsterRunStatus, | |
) |
OlderNewer