aap-utils 0.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 +27 -1
- {aap_utils-0.1.dist-info → aap_utils-0.1.2.dist-info}/METADATA +7 -2
- aap_utils-0.1.2.dist-info/RECORD +6 -0
- {aap_utils-0.1.dist-info → aap_utils-0.1.2.dist-info}/WHEEL +1 -1
- aap_utils-0.1.dist-info/RECORD +0 -6
- {aap_utils-0.1.dist-info → aap_utils-0.1.2.dist-info}/top_level.txt +0 -0
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,5 +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.")
|
32
|
+
print("Failed to register IP after 10 attempts.")
|
29
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:
|
3
|
-
Version: 0.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,,
|
aap_utils-0.1.dist-info/RECORD
DELETED
@@ -1,6 +0,0 @@
|
|
1
|
-
aap_utils/__init__.py,sha256=OALCpHMgWzr-3Lu7eKwalsw5GNCwWWkETUPHOqfGXsg,36
|
2
|
-
aap_utils/register.py,sha256=Tv9252qK85Arbl-iZbtu8F2wz7oU7E-EgrH1I2fsqz4,1023
|
3
|
-
aap_utils-0.1.dist-info/METADATA,sha256=36CrDww90sppXrnXQg56bIO7OQbJhtjpvrmDsl_fmPk,344
|
4
|
-
aap_utils-0.1.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
5
|
-
aap_utils-0.1.dist-info/top_level.txt,sha256=Qt5xmL8_0_jhMl9uA3lg-xnvs4nCEyVj1tBE4vnp36M,10
|
6
|
-
aap_utils-0.1.dist-info/RECORD,,
|
File without changes
|