# (C) 2022 Cadence Design Systems, Inc. (Cadence) 
# All rights reserved.
# TERMS FOR USE OF SAMPLE CODE The software below ("Sample Code") is
# provided to current licensees or subscribers of Cadence products or
# SaaS offerings (each a "Customer").
# Customer is hereby permitted to use, copy, and modify the Sample Code,
# subject to these terms. Cadence claims no rights to Customer's
# modifications. Modification of Sample Code is at Customer's sole and
# exclusive risk. Sample Code may require Customer to have a then
# current license or subscription to the applicable Cadence offering.
# THE SAMPLE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED.  OPENEYE DISCLAIMS ALL WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall Cadence be
# liable for any damages or liability in connection with the Sample Code
# or its use.

from floe.api import WorkFloe
from orionplatform.cubes import ShardReaderCube
from advanced_cubes import (ParallelExampleShardsToRecordsCube,
                            LogWriterCube,
                            )
# Declare WorkFloe
job = WorkFloe("Collection Reading Example")
job.title = "Reading Collections"
job.description = "Example of printing Records to the log"
job.classification = [["Educational", "Example", "Cube Development", "I/O", "Record", "Shard", "Collection"]]
job.tags = ["Educational", "Example", "Cube Development", "I/O", "Record", "Shard", "Collection"]
# Declare Cubes
read_collection = ShardReaderCube("read_collection")
shards_to_records = ParallelExampleShardsToRecordsCube("shards_to_records")
logwriter = LogWriterCube()
# Promote/Override Parameters
read_collection.promote_parameter("collection",
                                  promoted_name="collection")
# Add Cubes to WorkFloe
job.add_cubes(read_collection, shards_to_records, logwriter)
# Connect Cubes
read_collection.success.connect(shards_to_records.intake)
shards_to_records.success.connect(logwriter.intake)

if __name__ == "__main__":
    job.run()
