This file contains hidden or 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 coroflow import Pipeline, Node | |
import logging | |
from .data_collector import agg_data_deserialise, get_symbols, agg_data_update, agg_data_serialize | |
def main_sync(): | |
# Create Pipeline with a node for each function passed in. | |
# Data flows like so: | |
# get_symbols -> symbol_data -> agg_data_update |
This file contains hidden or 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
""" | |
Find list of ASX ETF symbols at asxetfs.com | |
""" | |
import os | |
import time | |
import logging | |
import pickle | |
import csv | |
import pandas as pd |
This file contains hidden or 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
""" | |
Find list of ASX ETF symbols at asxetfs.com | |
""" | |
import os | |
from coroflow import Pipeline, Node | |
import time | |
import logging | |
import pickle | |
import csv | |
import pandas as pd |
This file contains hidden or 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 asyncio | |
import time | |
tasks = [] | |
async def func(input_q, target_qs, task_id, param): | |
print(f"{task_id}: Initialised with param: {param}") | |
async def func_inner(input_q, target_qs, inpt): | |
print(f"{task_id}: Recieved input: {inpt}") |
This file contains hidden or 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 asyncio | |
import time | |
tasks = [] | |
def func(targets, task_id, param): | |
print(f"{task_id}: Initialised with param: {param}") | |
async def func_inner(targets, inpt): | |
await asyncio.sleep(1) # simulated IO delay |
This file contains hidden or 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 time | |
def func(targets, task_id, param=None): | |
print(f"{task_id}: Initialised with param: {param}") | |
while True: | |
inpt = (yield) | |
print(f"{task_id}: Received input: {inpt}") | |
time.sleep(1) # simulated IO delay | |
for target in targets: | |
print(f"{task_id}: T1 sending {inpt}") |
This file contains hidden or 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
CREATE OR REPLACE PROCEDURE ledger.make_ledger_entries() BEGIN | |
DECLARE unique_item_names ARRAY<STRING>; | |
DECLARE item_idx INT64 DEFAULT 0; | |
DECLARE current_table_name STRING; | |
-- Create some fake staging data for illustration | |
-- In reality, this could be ingested from a federated data source | |
CREATE OR REPLACE TEMPORARY TABLE new_purchases AS ( | |
SELECT * |
This file contains hidden or 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
WITH basket_1 AS ( | |
SELECT * | |
FROM UNNEST([ | |
STRUCT("apple" AS item_name, 2 AS quantity), | |
("banana", 0), | |
("pear", 4) | |
]) | |
), | |
basket_2 AS ( | |
SELECT * |
This file contains hidden or 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
DECLARE start_time TIMESTAMP; | |
DECLARE stop_time TIMESTAMP; | |
SET start_time = TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 30 DAY); | |
SET stop_time = TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 5 HOUR); | |
SELECT id | |
FROM my_dataset.my_table | |
WHERE created_at BETWEEN start_time and stop_time; |
This file contains hidden or 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
-- Example of a persistent function that use libraries stored in Google Cloud Storage | |
-- Taken from https://cloud.google.com/bigquery/docs/reference/standard-sql/user-defined-functions | |
CREATE OR REPLACE FUNCTION dataset.myFunc(a FLOAT64, b STRING) | |
RETURNS STRING | |
LANGUAGE js | |
OPTIONS ( | |
library=["gs://my-bucket/path/to/lib1.js", "gs://my-bucket/path/to/lib2.js"] | |
) | |
AS | |
""" |