Skip to content

Commit

Permalink
Add support for PR number and job trigger user
Browse files Browse the repository at this point in the history
  • Loading branch information
yoland68 committed Jul 12, 2024
1 parent 0478fbd commit 2f4ad36
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 9 deletions.
29 changes: 27 additions & 2 deletions action.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,21 +60,41 @@ def send_payload_to_api(
args, output_files_gcs_paths, workflow_name, start_time, end_time
):

is_pr = args.branch_name.endswith("/merge")
pr_number = None
if is_pr:
pr_number = args.branch_name.split("/")[0]

# Create the payload as a dictionary
# Should be mapping to https://github.com/Comfy-Org/registry-backend/blob/main/openapi.yml#L26
payload = {
"repo": args.repo,
"job_id": args.job_id,
"run_id": args.run_id,
"os": args.os,
"cuda_version": args.cuda_version,
"bucket_name": args.gsc_bucket_name,
"output_files_gcs_paths": output_files_gcs_paths,
# TODO: support comfy logs
# "comfy_logs_gcs_path":
"commit_hash": args.commit_hash,
"commit_time": args.commit_time,
"commit_message": args.commit_message,
"branch_name": args.branch_name,
"bucket_name": args.gsc_bucket_name,
"workflow_name": workflow_name,
"branch_name": args.branch_name,
"start_time": start_time,
"end_time": end_time,
# TODO: support these metrics
# "avg_vram": 0,
# "peak_vram": 0,
"pr_number": pr_number,
# TODO: support PR author
# "author": args.,
"job_trigger_user": args.job_trigger_user,
"comfy_run_flags": args.comfy_run_flags,
"python_version": args.python_version,
"torch_version": args.torch_version,
# "status": "WorkflowRunStatusStarted"
}

# Convert payload dictionary to a JSON string
Expand Down Expand Up @@ -157,8 +177,13 @@ def main(args):
)
parser.add_argument("--os", type=str, help="Operating system.")
parser.add_argument("--run-id", type=str, help="Github Run ID.")
parser.add_argument("--job-id", type=str, help="Github Run Job ID.")
parser.add_argument("--job-trigger-user", type=str, help="User who triggered the job")
parser.add_argument("--comfy-run-flags", type=str, help="Comfy run flags.")
parser.add_argument("--repo", type=str, help="Github repo.")
parser.add_argument("--cuda-version", type=str, help="CUDA version.")
parser.add_argument("--python-version", type=str, help="Python version.")
parser.add_argument("--torch-version", type=str, help="Torch version.")
parser.add_argument("--commit-hash", type=str, help="Commit hash.")
parser.add_argument("--commit-time", type=str, help="Commit time.")
parser.add_argument("--commit-message", type=str, help="Commit message.")
Expand Down
20 changes: 15 additions & 5 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ runs:
if: ${{ inputs.os != 'windows' }}
shell: bash -el {0}
run: |
python3 main.py > application.log 2>&1 &
python3 main.py ${{inputs.comfyui_flags}} > application.log 2>&1 &
- name: '[Unix] Check if the server is running'
if: ${{ inputs.os != 'windows' }}
Expand Down Expand Up @@ -202,16 +202,21 @@ runs:
--github-action-workflow-name "${{ github.workflow }}" \
--os "${{ inputs.os }}" \
--run-id "${{ github.run_id }}" \
--job-id "${{ github.job }}" \
--job-trigger-user "${{ github.actor }}" \
--gsc-bucket-name "${{ inputs.gcs_bucket_name }}" \
--workspace-path "${{ github.workspace }}" \
--output-file-prefix ${{ inputs.output_prefix }} \
--repo "${{ github.repository }}" \
--comfy-run-flags "${{ inputs.comfyui_flags }}" \
--python-version "${{ inputs.python_version }}" \
--torch-version "${{ inputs.torch_version }}" \
--cuda-version "${{ inputs.cuda_version }}" \
--commit-hash "${{ steps.unix_get_commit_details.outputs.commit_hash }}" \
--commit-time "${{ steps.unix_get_commit_details.outputs.commit_time }}" \
--commit-message "${{ steps.unix_get_commit_details.outputs.commit_title }}" \
--branch-name "${{ github.ref_name }}" \
--api-endpoint "${{ inputs.api_endpoint }}" \
${{ inputs.comfyui_flags }}
--api-endpoint "${{ inputs.api_endpoint }}"
# - name: '[Unix] Sleep for 10 minutes on failure'
# if: ${{ inputs.os != 'windows' && failure() }}
Expand Down Expand Up @@ -352,7 +357,7 @@ runs:
Write-Output $envGithubWorkspace
Write-Output "##############################"
conda activate gha-comfyui-${{ inputs.python_version }}-${{ inputs.torch_version }}
Start-Process powershell -ArgumentList "-File", "${{ github.action_path }}\start-server.ps1", "-GITHUB_WORKSPACE", "`"$envGithubWorkspace`"", "-CondaEnv", "`"gha-comfyui-${{ inputs.python_version }}-${{ inputs.torch_version }}`""
Start-Process powershell -ArgumentList "-File", "${{ github.action_path }}\start-server.ps1", "-GITHUB_WORKSPACE", "`"$envGithubWorkspace`"", "-CondaEnv", "`"gha-comfyui-${{ inputs.python_version }}-${{ inputs.torch_version }}`"", "-RunFlags", "`"${{ inputs.comfyui_flags}}`""
- name: '[Win] Check if the server is running'
if: ${{ inputs.os == 'windows' }}
Expand Down Expand Up @@ -387,16 +392,21 @@ runs:
--github-action-workflow-name "${{ github.workflow }}" `
--os "${{ inputs.os }}" `
--run-id "${{ github.run_id }}" `
--job-id "${{ github.job }}" `
--job-trigger-user "${{ github.actor }}" `
--gsc-bucket-name "${{ inputs.gcs_bucket_name }}" `
--workspace-path "${{ github.workspace }}" `
--output-file-prefix "${{ inputs.output_prefix }}" `
--repo "${{ github.repository }}" `
--comfy-run-flags "${{ inputs.comfyui_flags }}" `
--python-version "${{ inputs.python_version }}" `
--torch-version "${{ inputs.torch_version }}" `
--cuda-version "${{ inputs.cuda_version }}" `
--commit-hash "${{ steps.win_get_commit_details.outputs.commit_hash }}" `
--commit-time "${{ steps.win_get_commit_details.outputs.commit_time }}" `
--commit-message "${{ steps.win_get_commit_details.outputs.commit_title }}" `
--branch-name "${{ github.ref_name }}" `
--api-endpoint "${{ inputs.api_endpoint }}" `
${{ inputs.comfyui_flags }}
- name: '[Win] Upload Output Files'
uses: actions/upload-artifact@v4
Expand Down
5 changes: 3 additions & 2 deletions start-server.ps1
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# start-server.ps1
param (
[String]$GITHUB_WORKSPACE,
[String]$PythonFlags,
[String]$RunFlags,
[String]$CondaEnv
)

Expand All @@ -12,6 +12,7 @@ conda activate "$CondaEnv"

# Start the web server and redirect output to a log file
echo "Running Server"
python "$GITHUB_WORKSPACE/main.py" --force-fp16 *> "$GITHUB_WORKSPACE/application.log"
echo "python" "$GITHUB_WORKSPACE/main.py" $RunFlags
python "$GITHUB_WORKSPACE/main.py" $RunFlags *> "$GITHUB_WORKSPACE/application.log"

echo "Done"

0 comments on commit 2f4ad36

Please sign in to comment.