Skip to content

Commit 0ddce77

Browse files
committed
Infering API addr from git host
1 parent a7c2197 commit 0ddce77

3 files changed

Lines changed: 17 additions & 10 deletions

File tree

action.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,9 @@ inputs:
3939
required: false
4040
default: 'model_training.ipynb'
4141
git_host:
42-
description: Git host for the Algorithmia algorithm repository. Change to git.algorithmia.com if the algorithm is hosted on Algorithmia.
42+
description: Git host for the Algorithmia algorithm repository. Change to git.algorithmia.com if the algorithm is hosted on Algorithmia Marketplace or git.YOUR_DOMAIN for enterprise installations.
4343
required: false
4444
default: 'github.com'
45-
algorithmia_api:
46-
description: API endpoint Algorithmia installation, for enterprise customers.
47-
required: false
48-
default: 'https://api.algorithmia.com'
4945
runs:
5046
using: 'docker'
5147
image: 'Dockerfile'
@@ -61,6 +57,5 @@ runs:
6157
- ${{ inputs.model_path }}
6258
- ${{ inputs.notebook_path }}
6359
- ${{ inputs.git_host }}
64-
- ${{ inputs.algorithmia_host }}
6560

6661

src/action_main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
notebook_path = os.getenv("INPUT_NOTEBOOK_PATH")
1818
model_path = os.getenv("INPUT_MODEL_PATH")
1919
upload_path = os.getenv("INPUT_ALGORITHMIA_UPLOADPATH")
20-
algorithmia_api = os.getenv("INPUT_ALGORITHMIA_API")
20+
git_host = os.getenv("INPUT_GIT_HOST")
2121

2222
error_template_str = "Field '{}' not defined in workflow file. Please check your workflow configuration"
2323
if not algorithmia_api_key:
@@ -40,7 +40,7 @@
4040

4141
algorithmia_deployer = algorithmia_deployer.AlgorithmiaDeployer(
4242
api_key=algorithmia_api_key,
43-
api_address=algorithmia_api,
43+
git_host=git_host,
4444
username=algorithmia_username,
4545
algo_name=algorithmia_algo_name,
4646
model_path=model_path,

src/algorithmia_deployer.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@
77

88
class AlgorithmiaDeployer:
99
def __init__(
10-
self, api_key, api_address, username, algo_name, model_path, workspace_path,
10+
self, api_key, git_host, username, algo_name, model_path, workspace_path,
1111
) -> None:
12-
self.algo_client = Algorithmia.client(api_key, api_address)
12+
self.algo_client = Algorithmia.client(
13+
api_key, self._api_addr_from_git_host(git_host)
14+
)
1315
self.username = username
1416
self.algo_name = algo_name
1517
self.model_path = model_path
@@ -47,6 +49,16 @@ def upload_and_link_algo_model(
4749
f"Model file not found at {self.model_full_path}. Please check your workflow configuration."
4850
)
4951

52+
def _api_addr_from_git_host(self, git_host):
53+
# Examples:
54+
# git.devopsbay1.enthalpy.click -> https://api.devopsbay1.enthalpy.click
55+
# git.algorithmia.com -> https://api.algorithmia.com
56+
# git.test.algorithmia.com -> https://api.test.algorithmia.com
57+
domain = git_host.split("git.", 1)[1]
58+
api_addr = f"https://api.{domain}"
59+
print(f"API address for Algorithmia client is: {api_addr}")
60+
return api_addr
61+
5062
def _replace_placeholders(self, parametric_str):
5163
if "$ALGORITHMIA_USERNAME" in parametric_str:
5264
print(f"Replacing $ALGORITHMIA_USERNAME in {parametric_str}")

0 commit comments

Comments
 (0)