Skip to content

Commit b1d4781

Browse files
pieternsunishsheth2009
authored andcommitted
[Internal] Migrate workflows that need write access to use hosted runners (databricks#850)
Fixes databricks#848.
1 parent 8975d07 commit b1d4781

File tree

6 files changed

+247
-21
lines changed

6 files changed

+247
-21
lines changed

.github/workflows/external-message.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ on:
1313

1414
jobs:
1515
comment-on-pr:
16-
runs-on: ubuntu-latest
16+
runs-on:
17+
group: databricks-deco-testing-runner-group
18+
labels: ubuntu-latest-deco
19+
1720
permissions:
1821
pull-requests: write
1922

@@ -44,13 +47,13 @@ jobs:
4447
gh pr comment ${{ github.event.pull_request.number }} --body \
4548
"<!-- INTEGRATION_TESTS_MANUAL -->
4649
If integration tests don't run automatically, an authorized user can run them manually by following the instructions below:
47-
50+
4851
Trigger:
4952
[go/deco-tests-run/sdk-py](https://go/deco-tests-run/sdk-py)
5053
5154
Inputs:
5255
* PR number: ${{github.event.pull_request.number}}
5356
* Commit SHA: \`${{ env.COMMIT_SHA }}\`
54-
57+
5558
Checks will be approved automatically on success.
5659
"

.github/workflows/integration-tests.yml

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,16 @@ on:
66
types: [opened, synchronize]
77

88
merge_group:
9-
9+
1010

1111
jobs:
1212
check-token:
1313
name: Check secrets access
14-
runs-on: ubuntu-latest
14+
15+
runs-on:
16+
group: databricks-deco-testing-runner-group
17+
labels: ubuntu-latest-deco
18+
1519
environment: "test-trigger-is"
1620
outputs:
1721
has_token: ${{ steps.set-token-status.outputs.has_token }}
@@ -26,14 +30,18 @@ jobs:
2630
echo "DECO_WORKFLOW_TRIGGER_APP_ID is set. User has access to secrets."
2731
echo "::set-output name=has_token::true"
2832
fi
29-
33+
3034
trigger-tests:
3135
name: Trigger Tests
32-
runs-on: ubuntu-latest
36+
37+
runs-on:
38+
group: databricks-deco-testing-runner-group
39+
labels: ubuntu-latest-deco
40+
3341
needs: check-token
3442
if: github.event_name == 'pull_request' && needs.check-token.outputs.has_token == 'true'
3543
environment: "test-trigger-is"
36-
44+
3745
steps:
3846
- uses: actions/checkout@v3
3947

@@ -45,26 +53,30 @@ jobs:
4553
private-key: ${{ secrets.DECO_WORKFLOW_TRIGGER_PRIVATE_KEY }}
4654
owner: ${{ secrets.ORG_NAME }}
4755
repositories: ${{secrets.REPO_NAME}}
48-
56+
4957
- name: Trigger Workflow in Another Repo
5058
env:
5159
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
5260
run: |
5361
gh workflow run sdk-py-isolated-pr.yml -R ${{ secrets.ORG_NAME }}/${{secrets.REPO_NAME}} \
5462
--ref main \
5563
-f pull_request_number=${{ github.event.pull_request.number }} \
56-
-f commit_sha=${{ github.event.pull_request.head.sha }}
64+
-f commit_sha=${{ github.event.pull_request.head.sha }}
5765
58-
# Statuses and checks apply to specific commits (by hash).
66+
# Statuses and checks apply to specific commits (by hash).
5967
# Enforcement of required checks is done both at the PR level and the merge queue level.
60-
# In case of multiple commits in a single PR, the hash of the squashed commit
68+
# In case of multiple commits in a single PR, the hash of the squashed commit
6169
# will not match the one for the latest (approved) commit in the PR.
6270
# We auto approve the check for the merge queue for two reasons:
6371
# * Queue times out due to duration of tests.
6472
# * Avoid running integration tests twice, since it was already run at the tip of the branch before squashing.
6573
auto-approve:
6674
if: github.event_name == 'merge_group'
67-
runs-on: ubuntu-latest
75+
76+
runs-on:
77+
group: databricks-deco-testing-runner-group
78+
labels: ubuntu-latest-deco
79+
6880
steps:
6981
- name: Mark Check
7082
env:
@@ -75,4 +87,4 @@ jobs:
7587
-H "X-GitHub-Api-Version: 2022-11-28" \
7688
/repos/${{ github.repository }}/statuses/${{ github.sha }} \
7789
-f 'state=success' \
78-
-f 'context=Integration Tests Check'
90+
-f 'context=Integration Tests Check'

.github/workflows/release-test.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,15 @@ on:
55

66
jobs:
77
publish:
8-
runs-on: ubuntu-latest
8+
runs-on:
9+
group: databricks-deco-testing-runner-group
10+
labels: ubuntu-latest-deco
11+
912
environment: release-test
13+
1014
permissions:
1115
id-token: write
16+
1217
steps:
1318
- uses: actions/checkout@v3
1419

.github/workflows/release.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,16 @@ on:
77

88
jobs:
99
publish:
10-
runs-on: ubuntu-latest
10+
runs-on:
11+
group: databricks-deco-testing-runner-group
12+
labels: ubuntu-latest-deco
13+
1114
environment: release
15+
1216
permissions:
1317
contents: write
1418
id-token: write
19+
1520
steps:
1621
- uses: actions/checkout@v3
1722

databricks/sdk/mixins/open_ai_client.py

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
from databricks.sdk.service.serving import ServingEndpointsAPI
1+
import json as js
2+
from typing import Dict, Optional
3+
4+
from databricks.sdk.service.serving import (ExternalFunctionRequestMethod,
5+
ExternalFunctionResponse,
6+
ServingEndpointsAPI)
27

38

49
class ServingEndpointsExt(ServingEndpointsAPI):
@@ -50,3 +55,41 @@ def get_langchain_chat_open_ai_client(self, model):
5055
openai_api_base=self._api._cfg.host + "/serving-endpoints",
5156
api_key="no-token", # Passing in a placeholder to pass validations, this will not be used
5257
http_client=self._get_authorized_http_client())
58+
59+
def http_request(self,
60+
conn: str,
61+
method: ExternalFunctionRequestMethod,
62+
path: str,
63+
*,
64+
headers: Optional[Dict[str, str]] = None,
65+
json: Optional[Dict[str, str]] = None,
66+
params: Optional[Dict[str, str]] = None) -> ExternalFunctionResponse:
67+
"""Make external services call using the credentials stored in UC Connection.
68+
69+
**NOTE:** Experimental: This API may change or be removed in a future release without warning.
70+
71+
:param conn: str
72+
The connection name to use. This is required to identify the external connection.
73+
:param method: :class:`ExternalFunctionRequestMethod`
74+
The HTTP method to use (e.g., 'GET', 'POST'). This is required.
75+
:param path: str
76+
The relative path for the API endpoint. This is required.
77+
:param headers: Dict[str,str] (optional)
78+
Additional headers for the request. If not provided, only auth headers from connections would be
79+
passed.
80+
:param json: Dict[str,str] (optional)
81+
JSON payload for the request.
82+
:param params: Dict[str,str] (optional)
83+
Query parameters for the request.
84+
85+
:returns: :class:`ExternalFunctionResponse`
86+
"""
87+
88+
return super.http_request(
89+
connection_name=conn,
90+
method=method,
91+
path=path,
92+
headers=headers,
93+
json=js.dumps(json),
94+
params=js.dumps(params),
95+
)

0 commit comments

Comments
 (0)