Skip to content

Commit 6c7ce68

Browse files
committed
Adapt installer to custom instances
1 parent e0a216c commit 6c7ce68

1 file changed

Lines changed: 35 additions & 1 deletion

File tree

src/browsergym/workarena/install.py

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
from __future__ import annotations
2+
3+
import argparse
14
import html
25
import json
36
import logging
@@ -48,10 +51,28 @@
4851
UI_THEMES_UPDATE_SET,
4952
)
5053
from .api.user import set_user_preference
51-
from .instance import SNowInstance
54+
from .instance import SNowInstance as _BaseSNowInstance
5255
from .utils import url_login
5356

5457

58+
_CLI_INSTANCE_URL: str | None = None
59+
_CLI_INSTANCE_PASSWORD: str | None = None
60+
61+
62+
def SNowInstance():
63+
"""
64+
Wrapper around the standard SNowInstance that always uses CLI-provided credentials.
65+
"""
66+
if not _CLI_INSTANCE_URL or not _CLI_INSTANCE_PASSWORD:
67+
raise RuntimeError(
68+
"Installer requires --instance-url and --instance-password arguments."
69+
)
70+
return _BaseSNowInstance(
71+
snow_url=_CLI_INSTANCE_URL,
72+
snow_credentials=("admin", _CLI_INSTANCE_PASSWORD),
73+
)
74+
75+
5576
def _is_dev_portal_instance() -> bool:
5677
"""
5778
Check if the instance is a ServiceNow Developer Portal instance.
@@ -1105,6 +1126,19 @@ def main():
11051126
Entrypoint for package CLI installation command
11061127
11071128
"""
1129+
parser = argparse.ArgumentParser(description="Install WorkArena artifacts on a ServiceNow instance.")
1130+
parser.add_argument("--instance-url", required=True, help="URL of the target ServiceNow instance.")
1131+
parser.add_argument(
1132+
"--instance-password",
1133+
required=True,
1134+
help="Password for the admin user on the target ServiceNow instance.",
1135+
)
1136+
args = parser.parse_args()
1137+
1138+
global _CLI_INSTANCE_URL, _CLI_INSTANCE_PASSWORD
1139+
_CLI_INSTANCE_URL = args.instance_url
1140+
_CLI_INSTANCE_PASSWORD = args.instance_password
1141+
11081142
logging.basicConfig(level=logging.INFO)
11091143

11101144
try:

0 commit comments

Comments
 (0)