Prism
v0.1.9rc2
v0.1.9rc2
  • 👋Welcome to Prism!
  • Getting Started
    • Installation
    • Creating your first project
    • Why Prism?
  • Fundamentals
    • Tasks
      • tasks
      • hooks
        • hooks.sql
        • hooks.spark
        • hooks.dbt_ref
    • 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
    • PySpark
    • dbt
  • Agents
    • Overview
    • Docker
    • EC2
  • CLI
    • Command Line Interface
    • init
    • compile
    • connect
    • create
      • agent
      • task
      • trigger
    • graph
    • run
    • spark-submit
    • agent
      • apply
      • run
      • build
      • delete
  • Advanced features
    • Concurrency
    • Logging
    • Triggers
    • Retries
    • Python Client
  • API Reference
    • prism.task.PrismTask
    • @task(...)
    • @target(...)
    • @target_iterator(...)
    • tasks.ref(...)
    • hooks.sql(...)
    • hooks.dbt_ref(...)
  • Use Cases
    • Analytics on top of dbt
    • Machine Learning
  • Wiki
    • DAGs
Powered by GitBook
On this page
  1. Advanced features

Python Client

PreviousRetriesNextprism.task.PrismTask

Last updated 1 year ago

The primary interface for creating, manipulating, and executing Prism projects is the command line. However, starting with v0.1.5-alpha, users can also programmatically interact with Prism projects using Prism's Python client library. The core of this client is the PrismDAG object.

Below is the documentation for this object. Note that the arguments for each function are type-hinted.

PrismDAG(project_dir: pathlib.Path, log_level: str = "warn")

Instantiate a Prism DAG object

Parameters: - project_dir: Prism project directory - log_level: one of info, warn, error, or critical

PrismDAG.connect(connection_type: str)

Create a connection to an adapter. This replicates the functionality of the prism connect --type CLI command.

Parameters: - connection_type: Adapter type. Valid adapters are listed .

PrismDAG.compile( modules: Optional[List[str]] = None, all_downstream: bool = True )

Compile the Prism project. This replicates the functionality of the prism compile.

Parameters: - modules: A list of modules to compile. If this value is None, then all modules are compiled. - all_downstream: Whether to compile modules downstream of those in modules. The default is True.

PrismDAG.run( modules: Optional[List[str]] = None, all_upstream: bool = True, all_downstream: bool = True, full_tb: bool = True, user_context: Dict[Any, Any] = None )

Run the Prism project. This replicates the functionality of the prism run.

Parameters: - modules: A list of modules to compile. If this value is None, then all modules are compiled. - all_upstream: Whether to compile modules upstream of those in modules. The default is True. - all_downstream: Whether to compile modules downstream of those in modules. The default is True. - full_tb: Display full traceback if errors arise at any stage of the pipeline. The default is True. - user_context: dictionary with variables to overwrite prism_project.py.

PrismDAG.get_task_output( module_path: pathlib.Path, bool_run: bool = False, **kwargs )

Get output of the task at module_path. If bool_run == True, then run the project first. Note that if bool_run == False, then only tasks with a target can be parsed.

Parameters: - module_path: path to module (relative to modules/ folder) - bool_run: boolean indicating whether to run project first; default is False - **kwargs: keyword arguments for running

Returns: - task output

PrismDAG.get_pipeline_output( bool_run: bool = False, )

Get pipeline output, defined as the output associated with the last task in the project

Parameters: - bool_run: boolean indicating whether to run project first; default is False

Returns: - output associated with last task in the project

here