aap-utils 0.2.9__py3-none-any.whl → 0.2.11__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/cli.py CHANGED
@@ -4,6 +4,9 @@ import requests
4
4
  import socket # To get the hostname
5
5
 
6
6
  API_URL = "http://commit-svc.aiplatform/publish"
7
+ def is_debug_mode():
8
+ """Check if debug mode is enabled via the DEBUG environment variable."""
9
+ return os.getenv("DEBUG", "false").lower() == "true"
7
10
 
8
11
  def extract_default_image():
9
12
  """Extracts the image name from KERNEL_IMAGE if available and formats it."""
@@ -20,17 +23,8 @@ def validate_image_name(image_name):
20
23
  return bool(re.fullmatch(r'[a-z0-9_]+', image_name))
21
24
 
22
25
  def validate_tags(tags):
23
- """Validate tags: lowercase, alphanumeric with underscores, and no spaces."""
24
- tag_list = {tag.strip().lower() for tag in tags.split() if tag.strip()} # Use set to remove duplicates
25
-
26
- if not tag_list:
27
- return None # No valid tags
28
-
29
- for tag in tag_list:
30
- if not re.fullmatch(r'[a-z0-9_]+', tag):
31
- return None # Found an invalid tag
32
-
33
- return list(tag_list) # Convert back to list before returning
26
+ """Validate tag format: lowercase, only alphanumeric and underscores."""
27
+ return bool(re.fullmatch(r'[a-z0-9_]+', tags))
34
28
 
35
29
  def get_username():
36
30
  """Retrieve the username from the environment variable KERNEL_AP_USER or use 'unname'."""
@@ -60,11 +54,11 @@ def publish_env():
60
54
  print("Invalid image name. Use only lowercase letters, numbers, or underscores (_).")
61
55
 
62
56
  while True:
63
- tags = input("Enter tags (separated by space): ").strip()
57
+ tags = input("Enter tag (only 1 tag accepted): ").strip()
64
58
  formatted_tags = validate_tags(tags)
65
59
  if formatted_tags:
66
60
  break
67
- print("Invalid tags. Each tag must be lowercase, contain only letters, numbers, or underscores (_), and have no spaces.")
61
+ print("Invalid tag. Each tag must be lowercase, contain only letters, numbers, or underscores (_), and have no spaces.")
68
62
 
69
63
  data = {
70
64
  "username": username,
@@ -75,6 +69,9 @@ def publish_env():
75
69
  }
76
70
 
77
71
  print(f"Publishing environment: {username}/{image_name}:{';'.join(formatted_tags)}")
72
+
73
+ if is_debug_mode():
74
+ print(f"🔍 DEBUG: Sending data to API: {data}")
78
75
 
79
76
  try:
80
77
  response = requests.post(API_URL, json=data)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: aap_utils
3
- Version: 0.2.9
3
+ Version: 0.2.11
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,8 @@
1
+ aap_utils/__init__.py,sha256=g6G3i3a5ANDJWqFX2oPsLpP93aTaoTj0gkMQzeqQIJw,172
2
+ aap_utils/cli.py,sha256=kf18Sy1vqvHME3wnlARf4yZY7m5C1Z4DT_cTOfI9xU4,3578
3
+ aap_utils/register.py,sha256=J9tukByU1mcy4SoaJOoGY8jjzL9JMuNTZGtCBSwwon0,3823
4
+ aap_utils-0.2.11.dist-info/METADATA,sha256=Vlx2LkSOhJ_3nlIuiRlulegeD23rtH2UU2pwfRIMw5Q,347
5
+ aap_utils-0.2.11.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
6
+ aap_utils-0.2.11.dist-info/entry_points.txt,sha256=K-h2toLoqFxAg4Bx2r7FWggKgYnAX9zp9s4Ms4r-d6s,49
7
+ aap_utils-0.2.11.dist-info/top_level.txt,sha256=Qt5xmL8_0_jhMl9uA3lg-xnvs4nCEyVj1tBE4vnp36M,10
8
+ aap_utils-0.2.11.dist-info/RECORD,,
@@ -1,8 +0,0 @@
1
- aap_utils/__init__.py,sha256=g6G3i3a5ANDJWqFX2oPsLpP93aTaoTj0gkMQzeqQIJw,172
2
- aap_utils/cli.py,sha256=lEnZeDeKe9a7VthrTWeRx0SBox6Hi_GzwN1k4b0MKQI,3657
3
- aap_utils/register.py,sha256=J9tukByU1mcy4SoaJOoGY8jjzL9JMuNTZGtCBSwwon0,3823
4
- aap_utils-0.2.9.dist-info/METADATA,sha256=ts-P_XFJj3IrM2QlE8jZCcOYMxoblnmCFL75ll7yL6Y,346
5
- aap_utils-0.2.9.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
6
- aap_utils-0.2.9.dist-info/entry_points.txt,sha256=K-h2toLoqFxAg4Bx2r7FWggKgYnAX9zp9s4Ms4r-d6s,49
7
- aap_utils-0.2.9.dist-info/top_level.txt,sha256=Qt5xmL8_0_jhMl9uA3lg-xnvs4nCEyVj1tBE4vnp36M,10
8
- aap_utils-0.2.9.dist-info/RECORD,,