Skip to content

Commit

Permalink
use defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
lyon-tonic committed Mar 4, 2024
1 parent 4cb7dc7 commit ebc1a78
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 20 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,4 @@ jobs:
llm_response_path: ./sample.json
tonic_validate_project_id: ${{ secrets.TONIC_VALIDATE_PROJECT_ID }}
tonic_validate_api_key: ${{ secrets.TONIC_VALIDATE_API_KEY }}
commit_id: ${{ github.sha }}
repo_url: ${{ github.repository_url }}

8 changes: 0 additions & 8 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,6 @@ inputs:
description: 'Enter Tonic Validate server API key'
required: true
type: string
commit_id:
description: 'Commit ID for the current action run'
required: false
repo_url:
description: 'URL of the repository'
required: false
runs:
using: 'composite'
steps:
Expand All @@ -37,8 +31,6 @@ runs:
TONIC_VALIDATE_SERVER_PROJECT_ID: ${{ inputs.tonic_validate_project_id }}
TONIC_VALIDATE_SERVER_API_KEY: ${{ inputs.tonic_validate_api_key }}
VALIDATE_RESPONSES_PATH: ${{ github.workspace }}/${{ inputs.llm_response_path }}
GITHUB_COMMIT_ID: ${{ inputs.commit_id }}
GITHUB_REPO_URL: ${{ inputs.repo_url }}
run: python ${{ github.action_path }}/src/runner.py
shell: bash
branding:
Expand Down
16 changes: 6 additions & 10 deletions src/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
validate_api_key = os.environ.get('TONIC_VALIDATE_SERVER_API_KEY', None)
validate_project_id = os.environ.get('TONIC_VALIDATE_SERVER_PROJECT_ID', None)

repo_url = os.environ.get('GITHUB_REPO_URL', None)
commit_sha = os.environ.get('GITHUB_COMMIT_ID', None)

if validate_api_key is None:
exit('Error: You must specify TONIC_VALIDATE_SERVER_API_KEY, the API key for the Tonic Validate server')

Expand Down Expand Up @@ -53,14 +50,13 @@
scorer = ValidateScorer()
run = scorer.score_responses(llm_responses)

run_metadata = {}
github_server = os.environ.get('GITHUB_SERVER_URL')
github_repository = os.environ.get('GITHUB_REPOSITORY')
github_sha = os.environ.get('GITHUB_SHA')

if repo_url is not None and commit_sha is not None:
run_metadata = {
'commit_url': f"{repo_url}/commit/{commit_sha}"
}
else:
warnings.warn('The repository URL and the commit SHA must be passed into the runner for the run to be associated with a commit. You can set this up in the workflow file by passing in the deafult github variables, github.sha and github.repository_url')
run_metadata = {
'commit_url': f"{github_server}/{github_repository}/commit/{github_sha}"
}

validate_api = ValidateApi(validate_api_key)
validate_api.upload_run(validate_project_id, run, run_metadata)

0 comments on commit ebc1a78

Please sign in to comment.