Json
DataBricksAutoLoaderSource
Bases: SourceInterface
The Spark Auto Loader is used to read new data files as they arrive in cloud storage. Further information on Auto Loader is available here
Example
from rtdip_sdk.pipelines.sources import DataBricksAutoLoaderSource
from rtdip_sdk.pipelines.utilities import SparkSessionUtility
# Not required if using Databricks
spark = SparkSessionUtility(config={}).execute()
options = {}
path = "abfss://{FILE-SYSTEM}@{ACCOUNT-NAME}.dfs.core.windows.net/{PATH}/{FILE-NAME}
format = "{DESIRED-FILE-FORMAT}"
DataBricksAutoLoaderSource(spark, options, path, format).read_stream()
OR
DataBricksAutoLoaderSource(spark, options, path, format).read_batch()
from rtdip_sdk.pipelines.sources import DataBricksAutoLoaderSource
from rtdip_sdk.pipelines.utilities import SparkSessionUtility
# Not required if using Databricks
spark = SparkSessionUtility(config={}).execute()
options = {}
path = "https://s3.{REGION-CODE}.amazonaws.com/{BUCKET-NAME}/{KEY-NAME}"
format = "{DESIRED-FILE-FORMAT}"
DataBricksAutoLoaderSource(spark, options, path, format).read_stream()
OR
DataBricksAutoLoaderSource(spark, options, path, format).read_batch()
from rtdip_sdk.pipelines.sources import DataBricksAutoLoaderSource
from rtdip_sdk.pipelines.utilities import SparkSessionUtility
# Not required if using Databricks
spark = SparkSessionUtility(config={}).execute()
options = {}
path = "gs://{BUCKET-NAME}/{FILE-PATH}"
format = "{DESIRED-FILE-FORMAT}"
DataBricksAutoLoaderSource(spark, options, path, format).read_stream()
OR
DataBricksAutoLoaderSource(spark, options, path, format).read_batch()
Parameters:
Name | Type | Description | Default |
---|---|---|---|
spark |
SparkSession
|
Spark Session required to read data from cloud storage |
required |
options |
dict
|
Options that can be specified for configuring the Auto Loader. Further information on the options available are here |
required |
path |
str
|
The cloud storage path |
required |
format |
str
|
Specifies the file format to be read. Supported formats are available here |
required |
Source code in src/sdk/python/rtdip_sdk/pipelines/sources/spark/autoloader.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 |
|
system_type()
staticmethod
Attributes:
Name | Type | Description |
---|---|---|
SystemType |
Environment
|
Requires PYSPARK on Databricks |
Source code in src/sdk/python/rtdip_sdk/pipelines/sources/spark/autoloader.py
106 107 108 109 110 111 112 |
|
read_batch()
Raises:
Type | Description |
---|---|
NotImplementedError
|
Auto Loader only supports streaming reads. To perform a batch read, use the read_stream method of this component and specify the Trigger on the write_stream to be |
Source code in src/sdk/python/rtdip_sdk/pipelines/sources/spark/autoloader.py
130 131 132 133 134 135 136 137 |
|
read_stream()
Performs streaming reads of files in cloud storage.
Source code in src/sdk/python/rtdip_sdk/pipelines/sources/spark/autoloader.py
139 140 141 142 143 144 145 146 147 148 149 150 151 152 |
|
SparkDeltaSharingSource
Bases: SourceInterface
The Spark Delta Sharing Source is used to read data from a Delta table where Delta sharing is configured
Example
#Delta Sharing Source for Streaming Queries
from rtdip_sdk.pipelines.sources import SparkDeltaSharingSource
from rtdip_sdk.pipelines.utilities import SparkSessionUtility
# Not required if using Databricks
spark = SparkSessionUtility(config={}).execute()
delta_sharing_source = SparkDeltaSharingSource(
spark=spark,
options={
"maxFilesPerTrigger": 1000,
"ignoreChanges: True,
"startingVersion": 0
},
table_name="{YOUR-DELTA-TABLE-PATH}"
)
delta_sharing_source.read_stream()
#Delta Sharing Source for Batch Queries
from rtdip_sdk.pipelines.sources import SparkDeltaSharingSource
from rtdip_sdk.pipelines.utilities import SparkSessionUtility
# Not required if using Databricks
spark = SparkSessionUtility(config={}).execute()
delta_sharing_source = SparkDeltaSharingSource(
spark=spark,
options={
"versionAsOf": 0,
"timestampAsOf": "yyyy-mm-dd hh:mm:ss[.fffffffff]"
},
table_name="{YOUR-DELTA-TABLE-PATH}"
)
delta_sharing_source.read_batch()
Parameters:
Name | Type | Description | Default |
---|---|---|---|
spark |
SparkSession
|
Spark Session required to read data from a Delta table |
required |
options |
dict
|
Options that can be specified for a Delta Table read operation (See Attributes table below). Further information on the options is available here |
required |
table_path |
str
|
Path to credentials file and Delta table to query |
required |
Attributes:
Name | Type | Description |
---|---|---|
ignoreDeletes |
bool str
|
Ignore transactions that delete data at partition boundaries. (Streaming) |
ignoreChanges |
bool str
|
Pre-process updates if files had to be rewritten in the source table due to a data changing operation. (Streaming) |
startingVersion |
int str
|
The Delta Lake version to start from. (Streaming) |
startingTimestamp |
datetime str
|
The timestamp to start from. (Streaming) |
maxFilesPerTrigger |
int
|
How many new files to be considered in every micro-batch. The default is 1000. (Streaming) |
maxBytesPerTrigger |
int
|
How much data gets processed in each micro-batch. (Streaming) |
readChangeFeed |
bool str
|
Stream read the change data feed of the shared table. (Batch & Streaming) |
timestampAsOf |
datetime str
|
Query the Delta Table from a specific point in time. (Batch) |
versionAsOf |
int str
|
Query the Delta Table from a specific version. (Batch) |
Source code in src/sdk/python/rtdip_sdk/pipelines/sources/spark/delta_sharing.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
|
system_type()
staticmethod
Attributes:
Name | Type | Description |
---|---|---|
SystemType |
Environment
|
Requires PYSPARK |
Source code in src/sdk/python/rtdip_sdk/pipelines/sources/spark/delta_sharing.py
98 99 100 101 102 103 104 |
|
read_batch()
Reads batch data from Delta. Most of the options provided by the Apache Spark DataFrame read API are supported for performing batch reads on Delta tables.
Source code in src/sdk/python/rtdip_sdk/pipelines/sources/spark/delta_sharing.py
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
|
read_stream()
Reads streaming data from Delta. All of the data in the table is processed as well as any new data that arrives after the stream started. .load() can take table name or path.
Source code in src/sdk/python/rtdip_sdk/pipelines/sources/spark/delta_sharing.py
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
|
SparkEventhubSource
Bases: SourceInterface
This Spark source class is used to read batch or streaming data from Eventhubs. Eventhub configurations need to be specified as options in a dictionary. Additionally, there are more optional configurations which can be found here. If using startingPosition or endingPosition make sure to check out the Event Position section for more details and examples.
Example
#Eventhub Source for Streaming Queries
from rtdip_sdk.pipelines.sources import SparkEventhubSource
from rtdip_sdk.pipelines.utilities import SparkSessionUtility
import json
# Not required if using Databricks
spark = SparkSessionUtility(config={}).execute()
connectionString = "Endpoint=sb://{NAMESPACE}.servicebus.windows.net/;SharedAccessKeyName={ACCESS_KEY_NAME};SharedAccessKey={ACCESS_KEY}=;EntityPath={EVENT_HUB_NAME}"
startingEventPosition = {
"offset": -1,
"seqNo": -1,
"enqueuedTime": None,
"isInclusive": True
}
eventhub_source = SparkEventhubSource(
spark=spark,
options = {
"eventhubs.connectionString": connectionString,
"eventhubs.consumerGroup": "{YOUR-CONSUMER-GROUP}",
"eventhubs.startingPosition": json.dumps(startingEventPosition),
"maxEventsPerTrigger" : 1000
}
)
eventhub_source.read_stream()
#Eventhub Source for Batch Queries
from rtdip_sdk.pipelines.sources import SparkEventhubSource
from rtdip_sdk.pipelines.utilities import SparkSessionUtility
import json
# Not required if using Databricks
spark = SparkSessionUtility(config={}).execute()
connectionString = "Endpoint=sb://{NAMESPACE}.servicebus.windows.net/;SharedAccessKeyName={ACCESS_KEY_NAME};SharedAccessKey={ACCESS_KEY}=;EntityPath={EVENT_HUB_NAME}"
startingEventPosition = {
"offset": -1,
"seqNo": -1,
"enqueuedTime": None,
"isInclusive": True
}
endingEventPosition = {
"offset": None,
"seqNo": -1,
"enqueuedTime": endTime,
"isInclusive": True
}
eventhub_source = SparkEventhubSource(
spark,
options = {
"eventhubs.connectionString": connectionString,
"eventhubs.consumerGroup": "{YOUR-CONSUMER-GROUP}",
"eventhubs.startingPosition": json.dumps(startingEventPosition),
"eventhubs.endingPosition": json.dumps(endingEventPosition)
}
)
eventhub_source.read_batch()
Parameters:
Name | Type | Description | Default |
---|---|---|---|
spark |
SparkSession
|
Spark Session |
required |
options |
dict
|
A dictionary of Eventhub configurations (See Attributes table below) |
required |
Attributes:
Name | Type | Description |
---|---|---|
eventhubs.connectionString |
str
|
Eventhubs connection string is required to connect to the Eventhubs service. (Streaming and Batch) |
eventhubs.consumerGroup |
str
|
A consumer group is a view of an entire eventhub. Consumer groups enable multiple consuming applications to each have a separate view of the event stream, and to read the stream independently at their own pace and with their own offsets. (Streaming and Batch) |
eventhubs.startingPosition |
JSON str
|
The starting position for your Structured Streaming job. If a specific EventPosition is not set for a partition using startingPositions, then we use the EventPosition set in startingPosition. If nothing is set in either option, we will begin consuming from the end of the partition. (Streaming and Batch) |
eventhubs.endingPosition |
JSON str
|
(JSON str): The ending position of a batch query. This works the same as startingPosition. (Batch) |
maxEventsPerTrigger |
long
|
Rate limit on maximum number of events processed per trigger interval. The specified total number of events will be proportionally split across partitions of different volume. (Stream) |
Source code in src/sdk/python/rtdip_sdk/pipelines/sources/spark/eventhub.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 |
|
system_type()
staticmethod
Attributes:
Name | Type | Description |
---|---|---|
SystemType |
Environment
|
Requires PYSPARK |
Source code in src/sdk/python/rtdip_sdk/pipelines/sources/spark/eventhub.py
124 125 126 127 128 129 130 |
|
read_batch()
Reads batch data from Eventhubs.
Source code in src/sdk/python/rtdip_sdk/pipelines/sources/spark/eventhub.py
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 |
|
read_stream()
Reads streaming data from Eventhubs.
Source code in src/sdk/python/rtdip_sdk/pipelines/sources/spark/eventhub.py
172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 |
|
SparkIoThubSource
Bases: SourceInterface
This Spark source class is used to read batch or streaming data from an IoT Hub. IoT Hub configurations need to be specified as options in a dictionary. Additionally, there are more optional configurations which can be found here. If using startingPosition or endingPosition make sure to check out the Event Position section for more details and examples.
Example
#IoT Hub Source for Streaming Queries
from rtdip_sdk.pipelines.sources import SparkIoThubSource
from rtdip_sdk.pipelines.utilities import SparkSessionUtility
import json
# Not required if using Databricks
spark = SparkSessionUtility(config={}).execute()
connectionString = "Endpoint=sb://{NAMESPACE}.servicebus.windows.net/;SharedAccessKeyName={ACCESS_KEY_NAME};SharedAccessKey={ACCESS_KEY}=;EntityPath={EVENT_HUB_NAME}"
startingEventPosition = {
"offset": -1,
"seqNo": -1,
"enqueuedTime": None,
"isInclusive": True
}
iot_hub_source = SparkIoThubSource(
spark=spark,
options = {
"eventhubs.connectionString": connectionString,
"eventhubs.consumerGroup": "{YOUR-CONSUMER-GROUP}",
"eventhubs.startingPosition": json.dumps(startingEventPosition),
"maxEventsPerTrigger" : 1000
}
)
iot_hub_source.read_stream()
#IoT Hub Source for Batch Queries
from rtdip_sdk.pipelines.sources import SparkIoThubSource
from rtdip_sdk.pipelines.utilities import SparkSessionUtility
import json
# Not required if using Databricks
spark = SparkSessionUtility(config={}).execute()
connectionString = "Endpoint=sb://{NAMESPACE}.servicebus.windows.net/;SharedAccessKeyName={ACCESS_KEY_NAME};SharedAccessKey={ACCESS_KEY}=;EntityPath={EVENT_HUB_NAME}"
startingEventPosition = {
"offset": -1,
"seqNo": -1,
"enqueuedTime": None,
"isInclusive": True
}
endingEventPosition = {
"offset": None,
"seqNo": -1,
"enqueuedTime": endTime,
"isInclusive": True
}
iot_hub_source = SparkIoThubSource(
spark,
options = {
"eventhubs.connectionString": connectionString,
"eventhubs.consumerGroup": "{YOUR-CONSUMER-GROUP}",
"eventhubs.startingPosition": json.dumps(startingEventPosition),
"eventhubs.endingPosition": json.dumps(endingEventPosition)
}
)
iot_hub_source.read_batch()
Parameters:
Name | Type | Description | Default |
---|---|---|---|
spark |
SparkSession
|
Spark Session |
required |
options |
dict
|
A dictionary of IoT Hub configurations (See Attributes table below) |
required |
Attributes:
Name | Type | Description |
---|---|---|
eventhubs.connectionString |
str
|
IoT Hub connection string is required to connect to the Eventhubs service. (Streaming and Batch) |
eventhubs.consumerGroup |
str
|
A consumer group is a view of an entire IoT Hub. Consumer groups enable multiple consuming applications to each have a separate view of the event stream, and to read the stream independently at their own pace and with their own offsets. (Streaming and Batch) |
eventhubs.startingPosition |
JSON str
|
The starting position for your Structured Streaming job. If a specific EventPosition is not set for a partition using startingPositions, then we use the EventPosition set in startingPosition. If nothing is set in either option, we will begin consuming from the end of the partition. (Streaming and Batch) |
eventhubs.endingPosition |
JSON str
|
(JSON str): The ending position of a batch query. This works the same as startingPosition. (Batch) |
maxEventsPerTrigger |
long
|
Rate limit on maximum number of events processed per trigger interval. The specified total number of events will be proportionally split across partitions of different volume. (Stream) |
Source code in src/sdk/python/rtdip_sdk/pipelines/sources/spark/iot_hub.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 |
|
system_type()
staticmethod
Attributes:
Name | Type | Description |
---|---|---|
SystemType |
Environment
|
Requires PYSPARK |
Source code in src/sdk/python/rtdip_sdk/pipelines/sources/spark/iot_hub.py
124 125 126 127 128 129 130 |
|
read_batch()
Reads batch data from IoT Hubs.
Source code in src/sdk/python/rtdip_sdk/pipelines/sources/spark/iot_hub.py
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 |
|
read_stream()
Reads streaming data from IoT Hubs.
Source code in src/sdk/python/rtdip_sdk/pipelines/sources/spark/iot_hub.py
172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 |
|
SparkKafkaSource
Bases: SourceInterface
This Spark source class is used to read batch or streaming data from Kafka. Required and optional configurations can be found in the Attributes tables below.
Additionally, there are more optional configurations which can be found here.
Example
#Kafka Source for Streaming Queries
from rtdip_sdk.pipelines.sources import SparkKafkaSource
from rtdip_sdk.pipelines.utilities import SparkSessionUtility
# Not required if using Databricks
spark = SparkSessionUtility(config={}).execute()
kafka_source = SparkKafkaSource(
spark=spark,
options={
"kafka.bootstrap.servers": "{HOST_1}:{PORT_1},{HOST_2}:{PORT_2}",
"subscribe": "{TOPIC_1},{TOPIC_2}",
"includeHeaders", "true"
}
)
kafka_source.read_stream()
#Kafka Source for Batch Queries
from rtdip_sdk.pipelines.sources import SparkKafkaSource
from rtdip_sdk.pipelines.utilities import SparkSessionUtility
# Not required if using Databricks
spark = SparkSessionUtility(config={}).execute()
kafka_source = SparkKafkaSource(
spark=spark,
options={
"kafka.bootstrap.servers": "{HOST_1}:{PORT_1},{HOST_2}:{PORT_2}",
"subscribe": "{TOPIC_1},{TOPIC_2}",
"startingOffsets": "earliest",
"endingOffsets": "latest"
}
)
kafka_source.read_batch()
Parameters:
Name | Type | Description | Default |
---|---|---|---|
spark |
SparkSession
|
Spark Session |
required |
options |
dict
|
A dictionary of Kafka configurations (See Attributes tables below). For more information on configuration options see here |
required |
The following attributes are the most common configurations for Kafka.
The only configuration that must be set for the Kafka source for both batch and streaming queries is listed below.
Attributes:
Name | Type | Description |
---|---|---|
kafka.bootstrap.servers |
A comma-separated list of host︰port
|
The Kafka "bootstrap.servers" configuration. (Streaming and Batch) |
There are multiple ways of specifying which topics to subscribe to. You should provide only one of these attributes:
Attributes:
Name | Type | Description |
---|---|---|
assign |
json string {"topicA"︰[0,1],"topicB"︰[2,4]}
|
Specific TopicPartitions to consume. Only one of "assign", "subscribe" or "subscribePattern" options can be specified for Kafka source. (Streaming and Batch) |
subscribe |
A comma-separated list of topics
|
The topic list to subscribe. Only one of "assign", "subscribe" or "subscribePattern" options can be specified for Kafka source. (Streaming and Batch) |
subscribePattern |
Java regex string
|
The pattern used to subscribe to topic(s). Only one of "assign, "subscribe" or "subscribePattern" options can be specified for Kafka source. (Streaming and Batch) |
The following configurations are optional:
Attributes:
Name | Type | Description |
---|---|---|
startingTimestamp |
timestamp str
|
The start point of timestamp when a query is started, a string specifying a starting timestamp for all partitions in topics being subscribed. Please refer the note on starting timestamp offset options below. (Streaming and Batch) |
startingOffsetsByTimestamp |
JSON str
|
The start point of timestamp when a query is started, a json string specifying a starting timestamp for each TopicPartition. Please refer the note on starting timestamp offset options below. (Streaming and Batch) |
startingOffsets |
"earliest", "latest" (streaming only), or JSON string
|
The start point when a query is started, either "earliest" which is from the earliest offsets, "latest" which is just from the latest offsets, or a json string specifying a starting offset for each TopicPartition. In the json, -2 as an offset can be used to refer to earliest, -1 to latest. |
endingTimestamp |
timestamp str
|
The end point when a batch query is ended, a json string specifying an ending timestamp for all partitions in topics being subscribed. Please refer the note on ending timestamp offset options below. (Batch) |
endingOffsetsByTimestamp |
JSON str
|
The end point when a batch query is ended, a json string specifying an ending timestamp for each TopicPartition. Please refer the note on ending timestamp offset options below. (Batch) |
endingOffsets |
latest or JSON str
|
The end point when a batch query is ended, either "latest" which is just referred to the latest, or a json string specifying an ending offset for each TopicPartition. In the json, -1 as an offset can be used to refer to latest, and -2 (earliest) as an offset is not allowed. (Batch) |
maxOffsetsPerTrigger |
long
|
Rate limit on maximum number of offsets processed per trigger interval. The specified total number of offsets will be proportionally split across topicPartitions of different volume. (Streaming) |
minOffsetsPerTrigger |
long
|
Minimum number of offsets to be processed per trigger interval. The specified total number of offsets will be proportionally split across topicPartitions of different volume. (Streaming) |
failOnDataLoss |
bool
|
Whether to fail the query when it's possible that data is lost (e.g., topics are deleted, or offsets are out of range). This may be a false alarm. You can disable it when it doesn't work as you expected. |
minPartitions |
int
|
Desired minimum number of partitions to read from Kafka. By default, Spark has a 1-1 mapping of topicPartitions to Spark partitions consuming from Kafka. (Streaming and Batch) |
includeHeaders |
bool
|
Whether to include the Kafka headers in the row. (Streaming and Batch) |
Starting Timestamp Offset Note
If Kafka doesn't return the matched offset, the behavior will follow to the value of the option startingOffsetsByTimestampStrategy
.
startingTimestamp
takes precedence over startingOffsetsByTimestamp
and startingOffsets.
For streaming queries, this only applies when a new query is started, and that resuming will always pick up from where the query left off. Newly discovered partitions during a query will start at earliest.
Ending Timestamp Offset Note
If Kafka doesn't return the matched offset, the offset will be set to latest.
endingOffsetsByTimestamp
takes precedence over endingOffsets
.
Source code in src/sdk/python/rtdip_sdk/pipelines/sources/spark/kafka.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 |
|
system_type()
staticmethod
Attributes:
Name | Type | Description |
---|---|---|
SystemType |
Environment
|
Requires PYSPARK |
Source code in src/sdk/python/rtdip_sdk/pipelines/sources/spark/kafka.py
130 131 132 133 134 135 136 |
|
read_batch()
Reads batch data from Kafka.
Source code in src/sdk/python/rtdip_sdk/pipelines/sources/spark/kafka.py
155 156 157 158 159 160 161 162 163 164 165 166 167 |
|
read_stream()
Reads streaming data from Kafka.
Source code in src/sdk/python/rtdip_sdk/pipelines/sources/spark/kafka.py
169 170 171 172 173 174 175 176 177 178 179 180 181 |
|
SparkKafkaEventhubSource
Bases: SourceInterface
This Spark source class is used to read batch or streaming data from an Eventhub using the Kafka protocol. This enables Eventhubs to be used as a source in applications like Delta Live Tables or Databricks Serverless Jobs as the Spark Eventhubs JAR is not supported in these scenarios.
The dataframe returned is transformed to ensure the schema is as close to the Eventhub Spark source as possible. There are some minor differences:
offset
is dependent onx-opt-offset
being populated in the headers provided. If this is not found in the headers, the value will be nullpublisher
is dependent onx-opt-publisher
being populated in the headers provided. If this is not found in the headers, the value will be nullpartitionKey
is dependent onx-opt-partition-key
being populated in the headers provided. If this is not found in the headers, the value will be nullsystemProperties
are identified according to the list provided in the Eventhub documentation and IoT Hub documentation
Default settings will be specified if not provided in the options
parameter:
kafka.sasl.mechanism
will be set toPLAIN
kafka.security.protocol
will be set toSASL_SSL
kafka.request.timeout.ms
will be set to60000
kafka.session.timeout.ms
will be set to60000
Examples
#Kafka Source for Streaming Queries
from rtdip_sdk.pipelines.sources import SparkKafkaEventhubSource
from rtdip_sdk.pipelines.utilities import SparkSessionUtility
# Not required if using Databricks
spark = SparkSessionUtility(config={}).execute()
connectionString = "Endpoint=sb://{NAMESPACE}.servicebus.windows.net/;SharedAccessKeyName={ACCESS_KEY_NAME};SharedAccessKey={ACCESS_KEY}=;EntityPath={EVENT_HUB_NAME}"
consumerGroup = "{YOUR-CONSUMER-GROUP}"
kafka_eventhub_source = SparkKafkaEventhubSource(
spark=spark,
options={
"startingOffsets": "earliest",
"maxOffsetsPerTrigger": 10000,
"failOnDataLoss": "false",
},
connection_string=connectionString,
consumer_group="consumerGroup"
)
kafka_eventhub_source.read_stream()
#Kafka Source for Batch Queries
from rtdip_sdk.pipelines.sources import SparkKafkaEventhubSource
from rtdip_sdk.pipelines.utilities import SparkSessionUtility
# Not required if using Databricks
spark = SparkSessionUtility(config={}).execute()
connectionString = "Endpoint=sb://{NAMESPACE}.servicebus.windows.net/;SharedAccessKeyName={ACCESS_KEY_NAME};SharedAccessKey={ACCESS_KEY}=;EntityPath={EVENT_HUB_NAME}"
consumerGroup = "{YOUR-CONSUMER-GROUP}"
kafka_eventhub_source = SparkKafkaEventhubSource(
spark=spark,
options={
"startingOffsets": "earliest",
"endingOffsets": "latest",
"failOnDataLoss": "false"
},
connection_string=connectionString,
consumer_group="consumerGroup"
)
kafka_eventhub_source.read_batch()
Required and optional configurations can be found in the Attributes and Parameter tables below. Additionally, there are more optional configurations which can be found here.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
spark |
SparkSession
|
Spark Session |
required |
options |
dict
|
A dictionary of Kafka configurations (See Attributes tables below). For more information on configuration options see here |
required |
connection_string |
str
|
Eventhubs connection string is required to connect to the Eventhubs service. This must include the Eventhub name as the |
required |
consumer_group |
str
|
The Eventhub consumer group to use for the connection |
required |
decode_kafka_headers_to_amqp_properties |
optional bool
|
Perform decoding of Kafka headers into their AMQP properties. Default is True |
True
|
The only configuration that must be set for the Kafka source for both batch and streaming queries is listed below.
Attributes:
Name | Type | Description |
---|---|---|
kafka.bootstrap.servers |
A comma-separated list of host︰port
|
The Kafka "bootstrap.servers" configuration. (Streaming and Batch) |
There are multiple ways of specifying which topics to subscribe to. You should provide only one of these parameters:
Attributes:
Name | Type | Description |
---|---|---|
assign |
json string {"topicA"︰[0,1],"topicB"︰[2,4]}
|
Specific TopicPartitions to consume. Only one of "assign", "subscribe" or "subscribePattern" options can be specified for Kafka source. (Streaming and Batch) |
subscribe |
A comma-separated list of topics
|
The topic list to subscribe. Only one of "assign", "subscribe" or "subscribePattern" options can be specified for Kafka source. (Streaming and Batch) |
subscribePattern |
Java regex string
|
The pattern used to subscribe to topic(s). Only one of "assign, "subscribe" or "subscribePattern" options can be specified for Kafka source. (Streaming and Batch) |
The following configurations are optional:
Attributes:
Name | Type | Description |
---|---|---|
startingTimestamp |
timestamp str
|
The start point of timestamp when a query is started, a string specifying a starting timestamp for all partitions in topics being subscribed. Please refer the note on starting timestamp offset options below. (Streaming and Batch) |
startingOffsetsByTimestamp |
JSON str
|
The start point of timestamp when a query is started, a json string specifying a starting timestamp for each TopicPartition. Please refer the note on starting timestamp offset options below. (Streaming and Batch) |
startingOffsets |
"earliest", "latest" (streaming only), or JSON string
|
The start point when a query is started, either "earliest" which is from the earliest offsets, "latest" which is just from the latest offsets, or a json string specifying a starting offset for each TopicPartition. In the json, -2 as an offset can be used to refer to earliest, -1 to latest. |
endingTimestamp |
timestamp str
|
The end point when a batch query is ended, a json string specifying an ending timestamp for all partitions in topics being subscribed. Please refer the note on ending timestamp offset options below. (Batch) |
endingOffsetsByTimestamp |
JSON str
|
The end point when a batch query is ended, a json string specifying an ending timestamp for each TopicPartition. Please refer the note on ending timestamp offset options below. (Batch) |
endingOffsets |
latest or JSON str
|
The end point when a batch query is ended, either "latest" which is just referred to the latest, or a json string specifying an ending offset for each TopicPartition. In the json, -1 as an offset can be used to refer to latest, and -2 (earliest) as an offset is not allowed. (Batch) |
maxOffsetsPerTrigger |
long
|
Rate limit on maximum number of offsets processed per trigger interval. The specified total number of offsets will be proportionally split across topicPartitions of different volume. (Streaming) |
minOffsetsPerTrigger |
long
|
Minimum number of offsets to be processed per trigger interval. The specified total number of offsets will be proportionally split across topicPartitions of different volume. (Streaming) |
failOnDataLoss |
bool
|
Whether to fail the query when it's possible that data is lost (e.g., topics are deleted, or offsets are out of range). This may be a false alarm. You can disable it when it doesn't work as you expected. |
minPartitions |
int
|
Desired minimum number of partitions to read from Kafka. By default, Spark has a 1-1 mapping of topicPartitions to Spark partitions consuming from Kafka. (Streaming and Batch) |
includeHeaders |
bool
|
Whether to include the Kafka headers in the row. (Streaming and Batch) |
Starting Timestamp Offset Note
If Kafka doesn't return the matched offset, the behavior will follow to the value of the option startingOffsetsByTimestampStrategy
.
startingTimestamp
takes precedence over startingOffsetsByTimestamp
and startingOffsets.
For streaming queries, this only applies when a new query is started, and that resuming will always pick up from where the query left off. Newly discovered partitions during a query will start at earliest.
Ending Timestamp Offset Note
If Kafka doesn't return the matched offset, the offset will be set to latest.
endingOffsetsByTimestamp
takes precedence over endingOffsets
.
Source code in src/sdk/python/rtdip_sdk/pipelines/sources/spark/kafka_eventhub.py
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 |
|
system_type()
staticmethod
Attributes:
Name | Type | Description |
---|---|---|
SystemType |
Environment
|
Requires PYSPARK |
Source code in src/sdk/python/rtdip_sdk/pipelines/sources/spark/kafka_eventhub.py
191 192 193 194 195 196 197 |
|
read_batch()
Reads batch data from Kafka.
Source code in src/sdk/python/rtdip_sdk/pipelines/sources/spark/kafka_eventhub.py
369 370 371 372 373 374 375 376 377 378 379 380 381 382 |
|
read_stream()
Reads streaming data from Kafka.
Source code in src/sdk/python/rtdip_sdk/pipelines/sources/spark/kafka_eventhub.py
384 385 386 387 388 389 390 391 392 393 394 395 396 397 |
|
SparkKinesisSource
Bases: SourceInterface
The Spark Kinesis Source is used to read data from Kinesis in a Databricks environment. Structured streaming from Kinesis is not supported in open source Spark.
Example
from rtdip_sdk.pipelines.sources import SparkKinesisSource
from rtdip_sdk.pipelines.utilities import SparkSessionUtility
# Not required if using Databricks
spark = SparkSessionUtility(config={}).execute()
kinesis_source = SparkKinesisSource(
spark=spark,
options={
"awsAccessKey": "{AWS-ACCESS-KEY}",
"awsSecretKey": "{AWS-SECRET-KEY}",
"streamName": "{STREAM-NAME}",
"region": "{REGION}",
"endpoint": "https://kinesis.{REGION}.amazonaws.com",
"initialPosition": "earliest"
}
)
kinesis_source.read_stream()
OR
kinesis_source.read_batch()
Parameters:
Name | Type | Description | Default |
---|---|---|---|
spark |
SparkSession
|
Spark Session required to read data from Kinesis |
required |
options |
dict
|
Options that can be specified for a Kinesis read operation (See Attributes table below). Further information on the options is available here |
required |
Attributes:
Name | Type | Description |
---|---|---|
awsAccessKey |
str
|
AWS access key. |
awsSecretKey |
str
|
AWS secret access key corresponding to the access key. |
streamName |
List[str]
|
The stream names to subscribe to. |
region |
str
|
The region the streams are defined in. |
endpoint |
str
|
The regional endpoint for Kinesis Data Streams. |
initialPosition |
str
|
The point to start reading from; earliest, latest, or at_timestamp. |
Source code in src/sdk/python/rtdip_sdk/pipelines/sources/spark/kinesis.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
|
system_type()
staticmethod
Attributes:
Name | Type | Description |
---|---|---|
SystemType |
Environment
|
Requires PYSPARK_DATABRICKS |
Source code in src/sdk/python/rtdip_sdk/pipelines/sources/spark/kinesis.py
77 78 79 80 81 82 83 |
|
read_batch()
Raises:
Type | Description |
---|---|
NotImplementedError
|
Kinesis only supports streaming reads. To perform a batch read, use the read_stream method of this component and specify the Trigger on the write_stream to be |
Source code in src/sdk/python/rtdip_sdk/pipelines/sources/spark/kinesis.py
101 102 103 104 105 106 107 108 |
|
read_stream()
Reads streaming data from Kinesis. All of the data in the table is processed as well as any new data that arrives after the stream started.
Source code in src/sdk/python/rtdip_sdk/pipelines/sources/spark/kinesis.py
110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
|
BaseISOSource
Bases: SourceInterface
Base class for all the ISO Sources. It provides common functionality and helps in reducing the code redundancy.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
spark |
SparkSession
|
Spark Session instance |
required |
options |
dict
|
A dictionary of ISO Source specific configurations |
required |
Source code in src/sdk/python/rtdip_sdk/pipelines/sources/spark/iso/base_iso.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 |
|
pre_read_validation()
Ensures all the required options are provided and performs other validations. Returns: True if all checks are passed.
Source code in src/sdk/python/rtdip_sdk/pipelines/sources/spark/iso/base_iso.py
175 176 177 178 179 180 181 182 183 184 185 186 |
|
read_batch()
Spark entrypoint, It executes the entire process of pulling, transforming & fixing data. Returns: Final Spark DataFrame converted from Pandas DataFrame post-execution.
Source code in src/sdk/python/rtdip_sdk/pipelines/sources/spark/iso/base_iso.py
191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 |
|
read_stream()
By default, the streaming operation is not supported but child classes can override if ISO supports streaming.
Returns:
Type | Description |
---|---|
DataFrame
|
Final Spark DataFrame after all the processing. |
Source code in src/sdk/python/rtdip_sdk/pipelines/sources/spark/iso/base_iso.py
213 214 215 216 217 218 219 220 221 222 223 224 |
|
ERCOTDailyLoadISOSource
Bases: BaseISOSource
The ERCOT Daily Load ISO Source is used to read daily load data from ERCOT using WebScrapping. It supports actual and forecast data. To read more about the reports, visit the following URLs (The urls are only accessible if the requester/client is in US)-
For load type actual
: Actual System Load by Weather Zone
For load type forecast
: Seven-Day Load Forecast by Weather Zone
Parameters:
Name | Type | Description | Default |
---|---|---|---|
spark |
SparkSession
|
Spark Session instance |
required |
options |
dict
|
A dictionary of ISO Source specific configurations (See Attributes table below) |
required |
Attributes:
Name | Type | Description |
---|---|---|
load_type |
list
|
Must be one of |
date |
str
|
Must be in |
certificate_pfx_key |
str
|
The certificate key data or password received from ERCOT. |
certificate_pfx_key_contents |
str
|
The certificate data received from ERCOT, it could be base64 encoded. |
Please check the BaseISOSource for available methods.
BaseISOSource
BaseISOSource
Bases: SourceInterface
Base class for all the ISO Sources. It provides common functionality and helps in reducing the code redundancy.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
spark |
SparkSession
|
Spark Session instance |
required |
options |
dict
|
A dictionary of ISO Source specific configurations |
required |
Source code in src/sdk/python/rtdip_sdk/pipelines/sources/spark/iso/base_iso.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 |
|
pre_read_validation()
Ensures all the required options are provided and performs other validations. Returns: True if all checks are passed.
Source code in src/sdk/python/rtdip_sdk/pipelines/sources/spark/iso/base_iso.py
175 176 177 178 179 180 181 182 183 184 185 186 |
|
read_batch()
Spark entrypoint, It executes the entire process of pulling, transforming & fixing data. Returns: Final Spark DataFrame converted from Pandas DataFrame post-execution.
Source code in src/sdk/python/rtdip_sdk/pipelines/sources/spark/iso/base_iso.py
191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 |
|
read_stream()
By default, the streaming operation is not supported but child classes can override if ISO supports streaming.
Returns:
Type | Description |
---|---|
DataFrame
|
Final Spark DataFrame after all the processing. |
Source code in src/sdk/python/rtdip_sdk/pipelines/sources/spark/iso/base_iso.py
213 214 215 216 217 218 219 220 221 222 223 224 |
|
Source code in src/sdk/python/rtdip_sdk/pipelines/sources/spark/iso/ercot_daily_load_iso.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 |
|
MISODailyLoadISOSource
Bases: BaseISOSource
The MISO Daily Load ISO Source is used to read daily load data from MISO API. It supports both Actual and Forecast data.
To read more about the available reports from MISO API, download the file - Market Reports
From the list of reports in the file, it pulls the report named
Daily Forecast and Actual Load by Local Resource Zone
.
Actual data is available for one day minus from the given date.
Forecast data is available for next 6 day (inclusive of given date).
Example
from rtdip_sdk.pipelines.sources import MISODailyLoadISOSource
from rtdip_sdk.pipelines.utilities import SparkSessionUtility
# Not required if using Databricks
spark = SparkSessionUtility(config={}).execute()
miso_source = MISODailyLoadISOSource(
spark=spark,
options={
"load_type": "actual",
"date": "20230520",
}
)
miso_source.read_batch()
Parameters:
Name | Type | Description | Default |
---|---|---|---|
spark |
SparkSession
|
Spark Session instance |
required |
options |
dict
|
A dictionary of ISO Source specific configurations (See Attributes table below) |
required |
Attributes:
Name | Type | Description |
---|---|---|
load_type |
str
|
Must be one of |
date |
str
|
Must be in |
Please check the BaseISOSource for available methods.
BaseISOSource
BaseISOSource
Bases: SourceInterface
Base class for all the ISO Sources. It provides common functionality and helps in reducing the code redundancy.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
spark |
SparkSession
|
Spark Session instance |
required |
options |
dict
|
A dictionary of ISO Source specific configurations |
required |
Source code in src/sdk/python/rtdip_sdk/pipelines/sources/spark/iso/base_iso.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 |
|
pre_read_validation()
Ensures all the required options are provided and performs other validations. Returns: True if all checks are passed.
Source code in src/sdk/python/rtdip_sdk/pipelines/sources/spark/iso/base_iso.py
175 176 177 178 179 180 181 182 183 184 185 186 |
|
read_batch()
Spark entrypoint, It executes the entire process of pulling, transforming & fixing data. Returns: Final Spark DataFrame converted from Pandas DataFrame post-execution.
Source code in src/sdk/python/rtdip_sdk/pipelines/sources/spark/iso/base_iso.py
191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 |
|
read_stream()
By default, the streaming operation is not supported but child classes can override if ISO supports streaming.
Returns:
Type | Description |
---|---|
DataFrame
|
Final Spark DataFrame after all the processing. |
Source code in src/sdk/python/rtdip_sdk/pipelines/sources/spark/iso/base_iso.py
213 214 215 216 217 218 219 220 221 222 223 224 |
|
Source code in src/sdk/python/rtdip_sdk/pipelines/sources/spark/iso/miso_daily_load_iso.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 |
|
MISOHistoricalLoadISOSource
Bases: MISODailyLoadISOSource
The MISO Historical Load ISO Source is used to read historical load data from MISO API.
To read more about the available reports from MISO API, download the file - Market Reports
From the list of reports in the file, it pulls the report named
Historical Daily Forecast and Actual Load by Local Resource Zone
.
Example
from rtdip_sdk.pipelines.sources import MISOHistoricalLoadISOSource
from rtdip_sdk.pipelines.utilities import SparkSessionUtility
# Not required if using Databricks
spark = SparkSessionUtility(config={}).execute()
miso_source = MISOHistoricalLoadISOSource(
spark=spark,
options={
"start_date": "20230510",
"end_date": "20230520",
}
)
miso_source.read_batch()
Parameters:
Name | Type | Description | Default |
---|---|---|---|
spark |
SparkSession
|
Spark Session instance |
required |
options |
dict
|
A dictionary of ISO Source specific configurations (See Attributes table below) |
required |
Attributes:
Name | Type | Description |
---|---|---|
start_date |
str
|
Must be in |
end_date |
str
|
Must be in |
fill_missing |
str
|
Set to |
Please check the BaseISOSource for available methods.
BaseISOSource
BaseISOSource
Bases: SourceInterface
Base class for all the ISO Sources. It provides common functionality and helps in reducing the code redundancy.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
spark |
SparkSession
|
Spark Session instance |
required |
options |
dict
|
A dictionary of ISO Source specific configurations |
required |
Source code in src/sdk/python/rtdip_sdk/pipelines/sources/spark/iso/base_iso.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 |
|
pre_read_validation()
Ensures all the required options are provided and performs other validations. Returns: True if all checks are passed.
Source code in src/sdk/python/rtdip_sdk/pipelines/sources/spark/iso/base_iso.py
175 176 177 178 179 180 181 182 183 184 185 186 |
|
read_batch()
Spark entrypoint, It executes the entire process of pulling, transforming & fixing data. Returns: Final Spark DataFrame converted from Pandas DataFrame post-execution.
Source code in src/sdk/python/rtdip_sdk/pipelines/sources/spark/iso/base_iso.py
191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 |
|
read_stream()
By default, the streaming operation is not supported but child classes can override if ISO supports streaming.
Returns:
Type | Description |
---|---|
DataFrame
|
Final Spark DataFrame after all the processing. |
Source code in src/sdk/python/rtdip_sdk/pipelines/sources/spark/iso/base_iso.py
213 214 215 216 217 218 219 220 221 222 223 224 |
|
Source code in src/sdk/python/rtdip_sdk/pipelines/sources/spark/iso/miso_historical_load_iso.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 |
|
PJMDailyLoadISOSource
Bases: BaseISOSource
The PJM Daily Load ISO Source is used to read daily load data from PJM API. It supports both Actual and Forecast data. Actual will return 1 day, Forecast will return 7 days.
To read more about the reports, visit the following URLs -
Actual doc: ops_sum_prev_period
Forecast doc: load_frcstd_7_day
Example
from rtdip_sdk.pipelines.sources import PJMDailyLoadISOSource
from rtdip_sdk.pipelines.utilities import SparkSessionUtility
# Not required if using Databricks
spark = SparkSessionUtility(config={}).execute()
pjm_source = PJMDailyLoadISOSource(
spark=spark,
options={
"api_key": "{api_key}",
"load_type": "actual"
}
)
pjm_source.read_batch()
Parameters:
Name | Type | Description | Default |
---|---|---|---|
spark |
SparkSession
|
Spark Session instance |
required |
options |
dict
|
A dictionary of ISO Source specific configurations (See Attributes table below) |
required |
Attributes:
Name | Type | Description |
---|---|---|
api_key |
str
|
Must be a valid key from PJM, see api url |
load_type |
str
|
Must be one of |
Please check the BaseISOSource for available methods.
BaseISOSource
BaseISOSource
Bases: SourceInterface
Base class for all the ISO Sources. It provides common functionality and helps in reducing the code redundancy.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
spark |
SparkSession
|
Spark Session instance |
required |
options |
dict
|
A dictionary of ISO Source specific configurations |
required |
Source code in src/sdk/python/rtdip_sdk/pipelines/sources/spark/iso/base_iso.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 |
|
pre_read_validation()
Ensures all the required options are provided and performs other validations. Returns: True if all checks are passed.
Source code in src/sdk/python/rtdip_sdk/pipelines/sources/spark/iso/base_iso.py
175 176 177 178 179 180 181 182 183 184 185 186 |
|
read_batch()
Spark entrypoint, It executes the entire process of pulling, transforming & fixing data. Returns: Final Spark DataFrame converted from Pandas DataFrame post-execution.
Source code in src/sdk/python/rtdip_sdk/pipelines/sources/spark/iso/base_iso.py
191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 |
|
read_stream()
By default, the streaming operation is not supported but child classes can override if ISO supports streaming.
Returns:
Type | Description |
---|---|
DataFrame
|
Final Spark DataFrame after all the processing. |
Source code in src/sdk/python/rtdip_sdk/pipelines/sources/spark/iso/base_iso.py
213 214 215 216 217 218 219 220 221 222 223 224 |
|
Source code in src/sdk/python/rtdip_sdk/pipelines/sources/spark/iso/pjm_daily_load_iso.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 |
|
PJMDailyPricingISOSource
Bases: BaseISOSource
The PJM Daily Pricing ISO Source is used to retrieve Real-Time and Day-Ahead hourly data from PJM API. Real-Time will return data for T - 3 to T days and Day-Ahead will return T - 3 to T + 1 days data.
API: https://api.pjm.com/api/v1/ (must be a valid apy key from PJM)
Real-Time doc: https://dataminer2.pjm.com/feed/rt_hrl_lmps/definition
Day-Ahead doc: https://dataminer2.pjm.com/feed/da_hrl_lmps/definition
Example
from rtdip_sdk.pipelines.sources import PJMDailyPricingISOSource
from rtdip_sdk.pipelines.utilities import SparkSessionUtility
# Not required if using Databricks
spark = SparkSessionUtility(config={}).execute()
pjm_source = PJMDailyPricingISOSource(
spark=spark,
options={
"api_key": "{api_key}",
"load_type": "real_time"
}
)
pjm_source.read_batch()
Parameters:
Name | Type | Description | Default |
---|---|---|---|
spark |
SparkSession
|
Spark Session instance |
required |
options |
dict
|
A dictionary of ISO Source specific configurations (See Attributes table below) |
required |
Attributes:
Name | Type | Description |
---|---|---|
api_key |
str
|
Must be a valid key from PJM, see api url |
load_type |
str
|
Must be one of |
Please check the BaseISOSource for available methods.
BaseISOSource
BaseISOSource
Bases: SourceInterface
Base class for all the ISO Sources. It provides common functionality and helps in reducing the code redundancy.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
spark |
SparkSession
|
Spark Session instance |
required |
options |
dict
|
A dictionary of ISO Source specific configurations |
required |
Source code in src/sdk/python/rtdip_sdk/pipelines/sources/spark/iso/base_iso.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 |
|
pre_read_validation()
Ensures all the required options are provided and performs other validations. Returns: True if all checks are passed.
Source code in src/sdk/python/rtdip_sdk/pipelines/sources/spark/iso/base_iso.py
175 176 177 178 179 180 181 182 183 184 185 186 |
|
read_batch()
Spark entrypoint, It executes the entire process of pulling, transforming & fixing data. Returns: Final Spark DataFrame converted from Pandas DataFrame post-execution.
Source code in src/sdk/python/rtdip_sdk/pipelines/sources/spark/iso/base_iso.py
191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 |
|
read_stream()
By default, the streaming operation is not supported but child classes can override if ISO supports streaming.
Returns:
Type | Description |
---|---|
DataFrame
|
Final Spark DataFrame after all the processing. |
Source code in src/sdk/python/rtdip_sdk/pipelines/sources/spark/iso/base_iso.py
213 214 215 216 217 218 219 220 221 222 223 224 |
|
Source code in src/sdk/python/rtdip_sdk/pipelines/sources/spark/iso/pjm_daily_pricing_iso.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 |
|
PJMHistoricalPricingISOSource
Bases: PJMDailyPricingISOSource
The PJM Historical Pricing ISO Source is used to retrieve historical Real-Time and Day-Ahead hourly data from the PJM API.
API: https://api.pjm.com/api/v1/ (must be a valid apy key from PJM)
Real-Time doc: https://dataminer2.pjm.com/feed/rt_hrl_lmps/definition
Day-Ahead doc: https://dataminer2.pjm.com/feed/da_hrl_lmps/definition
The PJM Historical Pricing ISO Source accesses the same PJM endpoints as the daily pricing source but is tailored for retrieving data within a specified historical range defined by the start_date
and end_date
attributes.
Example
from rtdip_sdk.pipelines.sources import PJMHistoricalPricingISOSource
from rtdip_sdk.pipelines.utilities import SparkSessionUtility
# Not required if using Databricks
spark = SparkSessionUtility(config={}).execute()
pjm_source = PJMHistoricalPricingISOSource(
spark=spark,
options={
"api_key": "{api_key}",
"start_date": "2023-05-10",
"end_date": "2023-05-20",
}
)
pjm_source.read_batch()
Parameters:
Name | Type | Description | Default |
---|---|---|---|
spark |
SparkSession
|
The Spark Session instance. |
required |
options |
dict
|
A dictionary of ISO Source specific configurations. |
required |
Attributes:
Name | Type | Description |
---|---|---|
api_key |
str
|
A valid key from PJM required for authentication. |
load_type |
str
|
The type of data to retrieve, either |
start_date |
str
|
Must be in |
end_date |
str
|
Must be in |
Please refer to the BaseISOSource for available methods and further details.
BaseISOSource: ::: src.sdk.python.rtdip_sdk.pipelines.sources.spark.iso.base_iso
Source code in src/sdk/python/rtdip_sdk/pipelines/sources/spark/iso/pjm_historical_pricing_iso.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
|
PJMHistoricalLoadISOSource
Bases: PJMDailyLoadISOSource
The PJM Historical Load ISO Source is used to read historical load data from PJM API.
To read more about the reports, visit the following URLs -
Actual doc: ops_sum_prev_period
Forecast doc: load_frcstd_7_day
Historical is the same PJM endpoint as Actual, but is called repeatedly within a range established by the start_date & end_date attributes
Example
from rtdip_sdk.pipelines.sources import PJMHistoricalLoadISOSource
from rtdip_sdk.pipelines.utilities import SparkSessionUtility
# Not required if using Databricks
spark = SparkSessionUtility(config={}).execute()
pjm_source = PJMHistoricalLoadISOSource(
spark=spark,
options={
"api_key": "{api_key}",
"start_date": "20230510",
"end_date": "20230520",
}
)
pjm_source.read_batch()
Parameters:
Name | Type | Description | Default |
---|---|---|---|
spark |
SparkSession
|
Spark Session instance |
required |
options |
dict
|
A dictionary of ISO Source specific configurations (See Attributes table below) |
required |
Attributes:
Name | Type | Description |
---|---|---|
api_key |
str
|
Must be a valid key from PJM, see PJM documentation |
start_date |
str
|
Must be in |
end_date |
str
|
Must be in |
query_batch_days |
int
|
(optional) Number of days must be < 160 as per PJM & is defaulted to |
sleep_duration |
int
|
(optional) Number of seconds to sleep between request, defaulted to |
request_count |
int
|
(optional) Number of requests made to PJM endpoint before sleep_duration, currently defaulted to |
Please check the BaseISOSource for available methods.
BaseISOSource
BaseISOSource
Bases: SourceInterface
Base class for all the ISO Sources. It provides common functionality and helps in reducing the code redundancy.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
spark |
SparkSession
|
Spark Session instance |
required |
options |
dict
|
A dictionary of ISO Source specific configurations |
required |
Source code in src/sdk/python/rtdip_sdk/pipelines/sources/spark/iso/base_iso.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 |
|
pre_read_validation()
Ensures all the required options are provided and performs other validations. Returns: True if all checks are passed.
Source code in src/sdk/python/rtdip_sdk/pipelines/sources/spark/iso/base_iso.py
175 176 177 178 179 180 181 182 183 184 185 186 |
|
read_batch()
Spark entrypoint, It executes the entire process of pulling, transforming & fixing data. Returns: Final Spark DataFrame converted from Pandas DataFrame post-execution.
Source code in src/sdk/python/rtdip_sdk/pipelines/sources/spark/iso/base_iso.py
191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 |
|
read_stream()
By default, the streaming operation is not supported but child classes can override if ISO supports streaming.
Returns:
Type | Description |
---|---|
DataFrame
|
Final Spark DataFrame after all the processing. |
Source code in src/sdk/python/rtdip_sdk/pipelines/sources/spark/iso/base_iso.py
213 214 215 216 217 218 219 220 221 222 223 224 |
|
Source code in src/sdk/python/rtdip_sdk/pipelines/sources/spark/iso/pjm_historical_load_iso.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 |
|