Prism
v0.2.2
v0.2.2
  • 👋Welcome to Prism!
  • Getting Started
    • Installation
    • Creating your first project
    • Why Prism?
  • Fundamentals
    • Tasks
      • tasks
        • tasks.ref()
      • hooks
        • hooks.sql
        • hooks.spark
        • hooks.dbt_ref
        • hooks.get_connection
        • hooks.get_cursor
    • Targets
      • Multiple targets
    • Config files
      • prism_project.py
        • RUN_ID / SLUG
        • SYS_PATH_CONF
        • THREADS
        • PROFILE_YML_PATH / PROFILE
        • PRISM_LOGGER
        • TRIGGERS_YML_PATH / TRIGGERS
      • Profile YML
      • Triggers YML
    • Jinja
      • __file__ and Path
      • prism_project
      • wkdir
      • parent_dir
      • concat
      • env
  • Adapters
    • Overview
    • sql
      • BigQuery
      • Postgres
      • Redshift
      • Snowflake
      • Trino
      • Presto
    • PySpark
    • dbt
  • Agents
    • Overview
    • Docker
    • EC2
  • CLI
    • Command Line Interface
    • agent
      • apply
      • run
      • build
      • delete
    • compile
    • connect
    • create
      • agent
      • task
      • trigger
    • graph
    • init
    • run
    • spark-submit
  • Advanced features
    • Concurrency
    • Logging
    • Triggers
    • Retries
    • Python Client
  • API Reference
    • prism.task.PrismTask
    • @task(...)
    • @target(...)
    • @target_iterator(...)
    • TaskManager
      • tasks.ref(...)
    • PrismHooks
      • hooks.sql(...)
      • hooks.dbt_ref(...)
      • hooks.get_connection(...)
      • hooks.get_cursor(...)
    • prism.target.PrismTarget
  • Use Cases
    • Analytics on top of dbt
    • Machine Learning
  • Wiki
    • DAGs
Powered by GitBook
On this page
  • Usage
  • Example
  • Required arguments
  • Optional arguments
  1. CLI
  2. create

trigger

Usage

prism create trigger is used to create and update the triggers YML configuration file.

Usage: prism create trigger [OPTIONS]                                                                                               
                                                                                                                                     
 Create a triggers YML file at the TRIGGERS_YML_PATH in prism_project.py.                                                            
                                                                                                                                     
 Examples:                                                                                                                           
                                                                                                                                     
  • prism create trigger                                                                                                             
  • prism create trigger -v TRIGGERS_YML_PATH=/Users/.prism/triggers.yml                                                             
  • prism create trigger --context '{"TRIGGERS_YML_PATH": "/Users/.prism/triggers.yml"}'                                             
                                                                                                                                     
╭─ Options ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ --type       -t  [function]               Trigger type. Default is function                                                       │
│ --log-level  -l  [info|warn|error|debug]  Set the log level                                                                       │
│ --full-tb                                 Show the full traceback when an error occurs                                            │
│ --vars       -v  TEXT                     Variables as key value pairs. These overwrite variables in prism_project.py. All values │
│                                           are intepreted as strings.                                                              │
│ --context        TEXT                     Context as a dictionary. Must be a valid JSON. These overwrite variables in             │
│                                           prism_project.py                                                                        │
│ --help                                    Show this message and exit.                                                             │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

Here's what prism create trigger does under the hood:

  1. Parses the prism_project.py file and gets the TRIGGERS_YML_PATH value. If this value isn't specified, then it defaults to the project directory.

  2. It checks to see if TRIGGERS_YML_PATH exists

    • If it doesn't, it creates a file at TRIGGERS_YML_PATH and populates it with a trigger of type --type

    • If it does, it then adds a profile of type --type to the existing file

Example

Here's what the output will look like in Terminal (if there are no errors in the project):

$ prism create trigger --type function
--------------------------------------------------------------------------------
<HH:MM:SS> | INFO  | Running with prism v0.2.2...
<HH:MM:SS> | INFO  | Found project directory at /Users/my_first_project
 
<HH:MM:SS> | INFO  | RUNNING EVENT 'parsing prism_project.py'................................................ [RUN]
<HH:MM:SS> | INFO  | FINISHED EVENT 'parsing prism_project.py'............................................... [DONE in 0.03s]
 
<HH:MM:SS> | INFO  | Setting up triggers...
 
<HH:MM:SS> | INFO  | Done!
--------------------------------------------------------------------------------
$ 

Here's what the triggers.yml file looks like after running the above command:

# triggers.yml

triggers:
  <trigger name here>:
    type: function
    function: <import path to function>  # make sure your project has access to this import path via SYS_PATH_CONF!
    kwargs:  # this is optional!
      arg1: value1

Required arguments

Here are the required arguments you must specify with trigger:

  • --type : Trigger type. As of now, only type function is supported.

Optional arguments

Here are the optional arguments you can run with trigger:

  • --full-tb : Display full traceback if errors arise at any stage of the pipeline

  • --log-level: Log level, one of info, warn, error, or critical.

  • --vars: Prism variables as key-value pairs key=value. These overwrite any variable definitions in prism_project.py. All values are read as strings.

  • --context : Prism variables as JSON. Cannot co-exist with --vars. These overwrite any variable definitions in prism_project.py.

PrevioustaskNextgraph

Last updated 1 year ago