aap-utils 0.1.1__py3-none-any.whl → 0.1.2__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,7 @@
1
1
  import socket
2
2
  import requests
3
3
  import time
4
+ import os
4
5
 
5
6
  def register_demo(debug=False):
6
7
  for attempt in range(10):
@@ -12,6 +13,9 @@ def register_demo(debug=False):
12
13
  headers={"Content-Type": "application/json"}
13
14
  )
14
15
  if response.ok:
16
+ url, namespace = create_url()
17
+ # print(f"The demo service is at {namespace}.your_custorm_domain/demo/. Eg: {url}")
18
+ print(f"The demo service is at {url}")
15
19
  if debug:
16
20
  print("IP registered successfully.")
17
21
  return True
@@ -25,6 +29,27 @@ def register_demo(debug=False):
25
29
  time.sleep(2) # Wait for 2 seconds before retrying
26
30
 
27
31
  if debug:
28
- print("Failed to register IP after 10 attempts.")
29
- print("The demo service is registed at port 80.")
32
+ print("Failed to register IP after 10 attempts.")
30
33
  return False
34
+
35
+
36
+
37
+ def create_url(domain_name = "aiplatform.vcntt.tech"):
38
+ # Define the static domain name
39
+
40
+ # Read the KERNEL_NAMESPACE environment variable
41
+ kernel_namespace = os.getenv("KERNEL_NAMESPACE")
42
+
43
+ # Validate the environment variable
44
+ if not kernel_namespace:
45
+ kernel_namespace="undefined"
46
+
47
+ # Replace 'machinelearning' with 'appmachinepublic' in KERNEL_NAMESPACE
48
+ if kernel_namespace.startswith("machinelearning"):
49
+ transformed_namespace = kernel_namespace.replace("machinelearning", "appmachinepublic", 1)
50
+ else:
51
+ raise ValueError(f"The KERNEL_NAMESPACE '{kernel_namespace}' does not follow the expected format.")
52
+
53
+ # Create the final URL
54
+ url = f"https://{transformed_namespace}.{domain_name}/demo/"
55
+ return url, transformed_namespace
@@ -1,11 +1,16 @@
1
1
  Metadata-Version: 2.1
2
- Name: aap_utils
3
- Version: 0.1.1
2
+ Name: aap-utils
3
+ Version: 0.1.2
4
4
  Summary: A Python library for registering an IP address for AAP
5
+ Home-page: UNKNOWN
5
6
  Author: Minh Dang
6
7
  Author-email: danghoangminh86@gmail.com
8
+ License: UNKNOWN
9
+ Platform: UNKNOWN
7
10
  Classifier: Programming Language :: Python :: 3
8
11
  Classifier: License :: OSI Approved :: MIT License
9
12
  Classifier: Operating System :: OS Independent
10
13
  Requires-Dist: requests
11
14
 
15
+ UNKNOWN
16
+
@@ -0,0 +1,6 @@
1
+ aap_utils/__init__.py,sha256=OALCpHMgWzr-3Lu7eKwalsw5GNCwWWkETUPHOqfGXsg,36
2
+ aap_utils/register.py,sha256=aOVv1EhCqUfvIpmLgbWCCMcr-Sk-do3CkhZeVtjdEG0,2046
3
+ aap_utils-0.1.2.dist-info/METADATA,sha256=SB1Dci5aG5JfEEbOnUKCD8EhYCKMfPIf9shIZH6VvKg,409
4
+ aap_utils-0.1.2.dist-info/WHEEL,sha256=ewwEueio1C2XeHTvT17n8dZUJgOvyCWCt0WVNLClP9o,92
5
+ aap_utils-0.1.2.dist-info/top_level.txt,sha256=Qt5xmL8_0_jhMl9uA3lg-xnvs4nCEyVj1tBE4vnp36M,10
6
+ aap_utils-0.1.2.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.43.0)
2
+ Generator: bdist_wheel (0.37.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -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,,