aap-utils 0.2.19__tar.gz → 0.3.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: aap_utils
3
- Version: 0.2.19
3
+ Version: 0.3.0
4
4
  Summary: A Python library for registering an IP address for AAP
5
5
  Author: Minh Dang
6
6
  Author-email: danghoangminh86@gmail.com
@@ -95,10 +95,5 @@ def main():
95
95
  import sys
96
96
  if len(sys.argv) > 2 and sys.argv[1] == "push" and sys.argv[2] == "env":
97
97
  publish_env()
98
- elif len(sys.argv) > 1 and "password" in sys.argv[1]:
99
- # Example: python aap_utils.py b "\raiplatform@172.20.0.11's password:\n"
100
- print("aiplatform")
101
98
  else:
102
- print("Usage:")
103
- print(" aap_utils push env")
104
- print(" aap_utils b \"<prompt_bytes>\"")
99
+ print("Usage: aap_utils push env")
@@ -2,10 +2,37 @@ import socket
2
2
  import requests
3
3
  import time
4
4
  import os
5
+ import re
5
6
  from hydra import initialize, compose, initialize_config_dir
6
7
  from omegaconf import OmegaConf, DictConfig
7
8
 
8
9
  def register_demo(debug=False):
10
+ # --- Research Container Check ---
11
+ # Check if any environment variable starts with RESEARCH_SVC
12
+ is_research = any(key.startswith("RESEARCH_SVC") for key in os.environ)
13
+
14
+ if is_research:
15
+ vscode_proxy_uri = os.getenv("VSCODE_PROXY_URI", "")
16
+ if vscode_proxy_uri:
17
+ # Example transformation:
18
+ # From: https://appresearch34.aiplatform.vcntt.tech/proxy/{{port}}/
19
+ # To: https://appresearchpublic34.aiplatform.vcntt.tech/
20
+
21
+ # Logic: Replace 'appresearch' with 'appresearchpublic'
22
+ # and strip everything after the domain
23
+ match = re.search(r"https://(appresearch\d+)\.", vscode_proxy_uri)
24
+ if match:
25
+ subdomain = match.group(1).replace("appresearch", "appresearchpublic")
26
+ domain = vscode_proxy_uri.split(match.group(1) + ".")[-1].split("/")[0]
27
+ demo_url = f"https://{subdomain}.{domain}/"
28
+
29
+ print(f"Research environment detected. Demo service is at {demo_url}")
30
+ return True
31
+
32
+ if debug:
33
+ print("Research environment detected but VSCODE_PROXY_URI is missing or invalid.")
34
+
35
+ # --- Standard Registration Logic ---
9
36
  for attempt in range(10):
10
37
  try:
11
38
  local_ip = socket.gethostbyname(socket.gethostname())
@@ -20,7 +47,6 @@ def register_demo(debug=False):
20
47
  domain_name = argo_host.split("argowf.")[-1]
21
48
  url, namespace = create_url(domain_name=domain_name)
22
49
 
23
- # print(f"The demo service is at {namespace}.your_custorm_domain/demo/. Eg: {url}")
24
50
  print(f"The demo service is at {url}")
25
51
  if debug:
26
52
  print("IP registered successfully.")
@@ -29,10 +55,10 @@ def register_demo(debug=False):
29
55
  if debug:
30
56
  print(f"Attempt {attempt + 1}: Failed: {response.text}")
31
57
  except (socket.error, requests.exceptions.RequestException) as e:
32
- if debug: # Print errors only if debug is True
58
+ if debug:
33
59
  print(f"Attempt {attempt + 1}: Error: {e}")
34
60
 
35
- time.sleep(2) # Wait for 2 seconds before retrying
61
+ time.sleep(2)
36
62
 
37
63
  if debug:
38
64
  print("Failed to register IP after 10 attempts.")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: aap_utils
3
- Version: 0.2.19
3
+ Version: 0.3.0
4
4
  Summary: A Python library for registering an IP address for AAP
5
5
  Author: Minh Dang
6
6
  Author-email: danghoangminh86@gmail.com
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name="aap_utils", # The name of your library
5
- version="0.2.19",
5
+ version="0.3.0",
6
6
  description="A Python library for registering an IP address for AAP",
7
7
  author="Minh Dang",
8
8
  author_email="danghoangminh86@gmail.com",
File without changes
File without changes
File without changes