Package: acryl-datahub-actions
⚡ DataHub Actions FrameworkWelcome to DataHub Actions! The Actions framework makes responding to realtime changes in your Metadata Graph easy, enabling you to seamlessly integrateDataHubinto a broader events-based architecture.For a detailed introduction, check out theoriginal announcementof the DataHub Actions Framework at the DataHub April 2022 Town Hall. For a more in-depth look at use cases and concepts, check outDataHub Actions Concepts.QuickstartTo get started right away, check out theDataHub Actions QuickstartGuide.PrerequisitesThe DataHub Actions CLI commands are an extension of the basedatahubCLI commands. We recommend
first installing thedatahubCLI:python3-mpipinstall--upgradepipwheelsetuptools
python3-mpipinstall--upgradeacryl-datahub
datahub--versionNote that the Actions Framework requires a version ofacryl-datahub>= v0.8.34InstallationNext, simply install theacryl-datahub-actionspackage from PyPi:python3-mpipinstall--upgradepipwheelsetuptools
python3-mpipinstall--upgradeacryl-datahub-actions
datahubactionsversionConfiguring an ActionActions are configured using a YAML file, much in the same way DataHub ingestion sources are. An action configuration file consists of the followingAction Pipeline Name (Should be unique and static)Source ConfigurationsTransform + Filter ConfigurationsAction ConfigurationPipeline Options (Optional)DataHub API configs (Optional - required for select actions)With each component being independently pluggable and configurable.# 1. Required: Action Pipeline Name
name: <action-pipeline-name>

# 2. Required: Event Source - Where to source event from.
source:
  type: <source-type>
  config:
    # Event Source specific configs (map)

# 3a. Optional: Filter to run on events (map)
filter: 
  event_type: <filtered-event-type>
  event:
    # Filter event fields by exact-match
    <filtered-event-fields>

# 3b. Optional: Custom Transformers to run on events (array)
transform:
  - type: <transformer-type>
    config: 
      # Transformer-specific configs (map)

# 4. Required: Action - What action to take on events. 
action:
  type: <action-type>
  config:
    # Action-specific configs (map)

# 5. Optional: Additional pipeline options (error handling, etc)
options: 
  retry_count: 0 # The number of times to retry an Action with the same event. (If an exception is thrown). 0 by default. 
  failure_mode: "CONTINUE" # What to do when an event fails to be processed. Either 'CONTINUE' to make progress or 'THROW' to stop the pipeline. Either way, the failed event will be logged to a failed_events.log file. 
  failed_events_dir: "/tmp/datahub/actions"  # The directory in which to write a failed_events.log file that tracks events which fail to be processed. Defaults to "/tmp/logs/datahub/actions". 

# 6. Optional: DataHub API configuration
datahub:
  server: "http://localhost:8080" # Location of DataHub API
  # token: <your-access-token> # Required if Metadata Service Auth enabledExample: Hello WorldAn simple configuration file for a "Hello World" action, which simply prints all events it receives, is# 1. Action Pipeline Name
name: "hello_world"
# 2. Event Source: Where to source event from.
source:
  type: "kafka"
  config:
    connection:
      bootstrap: ${KAFKA_BOOTSTRAP_SERVER:-localhost:9092}
      schema_registry_url: ${SCHEMA_REGISTRY_URL:-http://localhost:8081}
# 3. Action: What action to take on events. 
action:
  type: "hello_world"We can modify this configuration further to filter for specific events, by adding a "filter" block.# 1. Action Pipeline Name
name: "hello_world"

# 2. Event Source - Where to source event from.
source:
  type: "kafka"
  config:
    connection:
      bootstrap: ${KAFKA_BOOTSTRAP_SERVER:-localhost:9092}
      schema_registry_url: ${SCHEMA_REGISTRY_URL:-http://localhost:8081}

# 3. Filter - Filter events that reach the Action
filter:
  event_type: "EntityChangeEvent_v1"
  event:
    category: "TAG"
    operation: "ADD"
    modifier: "urn:li:tag:pii"

# 4. Action - What action to take on events. 
action:
  type: "hello_world"Running an ActionTo run a new Action, just use theactionsCLI commanddatahub actions -c <config.yml>Once the Action is running, you will seeAction Pipeline with name '<action-pipeline-name>' is now running.Running multiple ActionsYou can run multiple actions pipeline within the same command. Simply provide multiple
config files by restating the "-c" command line argument.For example,datahub actions -c <config-1.yaml> -c <config-2.yaml>Running in debug modeSimply append the--debugflag to the CLI to run your action in debug mode.datahub actions -c <config.yaml> --debugStopping an ActionJust issue a Control-C as usual. You should see the Actions Pipeline shut down gracefully, with a small
summary of processing results.Actions Pipeline with name '<action-pipeline-name' has been stopped.Supported EventsTwo event types are currently supported. Read more about them below.Entity Change Event V1Metadata Change Log V1Supported Event SourcesCurrently, the only event source that is officially supported iskafka, which polls for events
via a Kafka Consumer.Kafka Event SourceSupported ActionsBy default, DataHub supports a set of standard actions plugins. These can be found inside the foldersrc/datahub-actions/plugins.Some pre-included Actions includeHello WorldExecutorDevelopmentBuild and TestNotice that we support all actions command using a separatedatahub-actionsCLI entry point. Feel free
to use this during development.# Build datahub-actions module
./gradlew datahub-actions:build

# Drop into virtual env
cd datahub-actions && source venv/bin/activate 

# Start hello world action 
datahub-actions actions -c ../examples/hello_world.yaml

# Start ingestion executor action
datahub-actions actions -c ../examples/executor.yaml

# Start multiple actions 
datahub-actions actions -c ../examples/executor.yaml -c ../examples/hello_world.yamlDeveloping a TransformerTo develop a new Transformer, check out theDeveloping a Transformerguide.Developing an ActionTo develop a new Action, check out theDeveloping an Actionguide.ContributingContributing guidelines follow those of themain DataHub project. We are accepting contributions for Actions, Transformers, and general framework improvements (tests, error handling, etc).ResourcesCheck out theoriginal announcementof the DataHub Actions Framework at the DataHub April 2022 Town Hall.LicenseApache 2.0