aap-utils 0.1.1__py3-none-any.whl → 0.1.3__py3-none-any.whl

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.
aap_utils/register.py CHANGED
@@ -1,6 +1,9 @@
1
1
  import socket
2
2
  import requests
3
3
  import time
4
+ import os
5
+ from hydra import initialize, compose
6
+ from omegaconf import OmegaConf, DictConfig
4
7
 
5
8
  def register_demo(debug=False):
6
9
  for attempt in range(10):
@@ -12,6 +15,13 @@ def register_demo(debug=False):
12
15
  headers={"Content-Type": "application/json"}
13
16
  )
14
17
  if response.ok:
18
+ response_json = response.json()
19
+ argo_host = response_json.get('ARGOWORKFLOW_HOST', 'http://argowf.aiplatform.vcntt.tech')
20
+ domain_name = argo_host.split("argowf.")[-1]
21
+ url, namespace = create_url(domain_name=domain_name)
22
+
23
+ # print(f"The demo service is at {namespace}.your_custorm_domain/demo/. Eg: {url}")
24
+ print(f"The demo service is at {url}")
15
25
  if debug:
16
26
  print("IP registered successfully.")
17
27
  return True
@@ -25,6 +35,46 @@ def register_demo(debug=False):
25
35
  time.sleep(2) # Wait for 2 seconds before retrying
26
36
 
27
37
  if debug:
28
- print("Failed to register IP after 10 attempts.")
29
- print("The demo service is registed at port 80.")
38
+ print("Failed to register IP after 10 attempts.")
30
39
  return False
40
+
41
+
42
+
43
+ def create_url(domain_name = "aiplatform.vcntt.tech"):
44
+ # Define the static domain name
45
+
46
+ # Read the KERNEL_NAMESPACE environment variable
47
+ kernel_namespace = os.getenv("KERNEL_NAMESPACE")
48
+
49
+ # Validate the environment variable
50
+ if not kernel_namespace:
51
+ kernel_namespace="undefined"
52
+
53
+ # Replace 'machinelearning' with 'appmachinepublic' in KERNEL_NAMESPACE
54
+ if kernel_namespace.startswith("machinelearning"):
55
+ transformed_namespace = kernel_namespace.replace("machinelearning", "appmachinepublic", 1)
56
+ else:
57
+ raise ValueError(f"The KERNEL_NAMESPACE '{kernel_namespace}' does not follow the expected format.")
58
+
59
+ # Create the final URL
60
+ url = f"https://{transformed_namespace}.{domain_name}"
61
+ return url, transformed_namespace
62
+
63
+
64
+ def get_args():
65
+ kcn_params = "config.yaml"
66
+ config_path="configs/config.yaml"
67
+ overrides = []
68
+
69
+ if os.environ.get('KCN_PARAMS') and os.environ.get('KCN_PARAMS') != '':
70
+ full_path = os.getenv('KCN_PARAMS')
71
+ config_path = os.path.join(config_path, kcn_params)
72
+ kcn_params = os.path.basename(full_path) # Extract the filename
73
+
74
+ if os.environ.get('KCN_OVERRIDES') and os.environ.get('KCN_OVERRIDES') != '':
75
+ overrides_env = os.getenv("KCN_OVERRIDES")
76
+ overrides = overrides_env.split('|') if overrides_env else []
77
+
78
+ with initialize(version_base=None, config_path=config_path):
79
+ args = compose(config_name=kcn_params)
80
+ return args
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: aap_utils
3
- Version: 0.1.1
3
+ Version: 0.1.3
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
@@ -0,0 +1,6 @@
1
+ aap_utils/__init__.py,sha256=OALCpHMgWzr-3Lu7eKwalsw5GNCwWWkETUPHOqfGXsg,36
2
+ aap_utils/register.py,sha256=YDUvUtoICYVMuuzYAueb34ZtGcYI8SJ6YxoNB3POyyQ,3069
3
+ aap_utils-0.1.3.dist-info/METADATA,sha256=8RqkF_j5hIRzy2czLQ8a5Kt_kjjnaEvZResid-aDL2g,346
4
+ aap_utils-0.1.3.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
5
+ aap_utils-0.1.3.dist-info/top_level.txt,sha256=Qt5xmL8_0_jhMl9uA3lg-xnvs4nCEyVj1tBE4vnp36M,10
6
+ aap_utils-0.1.3.dist-info/RECORD,,
@@ -1,6 +0,0 @@
1
- aap_utils/__init__.py,sha256=OALCpHMgWzr-3Lu7eKwalsw5GNCwWWkETUPHOqfGXsg,36
2
- aap_utils/register.py,sha256=cM0o2ehaz-Z6tEcAjF_EtJCJz_cRZXrpUC3TeHoq5Jw,1077
3
- aap_utils-0.1.1.dist-info/METADATA,sha256=hLHrQj9_tKp1X-uvq-xy8Ev7JAUNwVRL9EDq8nCkMIA,346
4
- aap_utils-0.1.1.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
5
- aap_utils-0.1.1.dist-info/top_level.txt,sha256=Qt5xmL8_0_jhMl9uA3lg-xnvs4nCEyVj1tBE4vnp36M,10
6
- aap_utils-0.1.1.dist-info/RECORD,,