1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] How to create trigger on specific file change?

Discussão em 'Python' iniciado por Stack, Novembro 30, 2025.

  1. Stack

    Stack Membro Participativo

    I'm using Buddy Works CI/CD. My use case is that I want to run auto evaluation via CI every time there is a push of changing a evaluation data file. I have tried a lot but fail. My current approach is fetch the commit and check for file name. But do we have a option that trigger on file change?

    - pipeline: evaluate
    name: Evaluate Model on Dataset Change
    refs:
    - refs/heads/main
    events:
    - type: PUSH
    refs:
    - refs/heads/main
    fail_on_prepare_env_warning: true
    actions:
    - action: evaluate_model
    type: BUILD
    docker_image_name: library/python
    docker_image_tag: 3.13
    execute_commands:
    - echo "Forcing full detection of changed dataset files..."
    - ""
    - "# Ensure full history so diff works"
    - git fetch origin main --unshallow || git fetch origin main
    - ""
    - "# Extract the last two commits on the remote main"
    - LAST_TWO=$(git rev-list origin/main -n 2)
    - AFTER=$(echo "$LAST_TWO" | sed -n 1p)
    - BEFORE=$(echo "$LAST_TWO" | sed -n 2p)
    - ""
    - "echo \"Before: $BEFORE\""
    - "echo \"After: $AFTER\""
    - ""
    - CHANGED_FILES=$(git diff --name-only "$BEFORE" "$AFTER" || true)
    - ""
    - echo "Changed files detected:"
    - echo "$CHANGED_FILES"
    - ""
    - if ! echo "$CHANGED_FILES" | grep -q '^dataset/'; then
    - ' echo "No dataset changes detected — skipping evaluation."'
    - exit 0
    - fi
    - ""
    - echo "Dataset changed → running evaluation..."
    - pip install -r requirements.txt
    - export PYTHONPATH=.
    - 'python scripts/run_evaluation.py '
    - ""
    shell: BASH

    Continue reading...

Compartilhe esta Página