Spaces:
Building
Building
Update config_provider.py
Browse files- config_provider.py +2 -38
config_provider.py
CHANGED
@@ -77,12 +77,6 @@ class ConfigProvider:
|
|
77 |
if 'projects' in config_data and len(config_data['projects']) > 0:
|
78 |
first_project = config_data['projects'][0]
|
79 |
log_debug(f"π Raw project data - last_update_date: {first_project.get('last_update_date')}")
|
80 |
-
# Check versions published status
|
81 |
-
if 'versions' in first_project:
|
82 |
-
for version in first_project['versions']:
|
83 |
-
if 'published' in version:
|
84 |
-
log_debug(f"π Version {version.get('no')} - raw published: {version['published']} (type: {type(version['published'])})")
|
85 |
-
|
86 |
|
87 |
# Ensure required fields
|
88 |
if 'config' not in config_data:
|
@@ -91,18 +85,6 @@ class ConfigProvider:
|
|
91 |
# Parse API configs (handle JSON strings)
|
92 |
if 'apis' in config_data:
|
93 |
cls._parse_api_configs(config_data['apis'])
|
94 |
-
|
95 |
-
# Fix boolean values in versions before validation
|
96 |
-
if 'projects' in config_data:
|
97 |
-
for project in config_data['projects']:
|
98 |
-
if 'versions' in project:
|
99 |
-
for version in project['versions']:
|
100 |
-
# Ensure published is boolean
|
101 |
-
if 'published' in version:
|
102 |
-
if isinstance(version['published'], str):
|
103 |
-
version['published'] = version['published'].lower() == 'true'
|
104 |
-
elif version['published'] is None:
|
105 |
-
version['published'] = False
|
106 |
|
107 |
# Validate and create model
|
108 |
cfg = ServiceConfig.model_validate(config_data)
|
@@ -179,18 +161,7 @@ class ConfigProvider:
|
|
179 |
# Load current config for race condition check
|
180 |
try:
|
181 |
current_config = cls._load()
|
182 |
-
|
183 |
-
# Ensure boolean values remain boolean in versions
|
184 |
-
if 'projects' in config_dict:
|
185 |
-
for project in config_dict['projects']:
|
186 |
-
if 'versions' in project:
|
187 |
-
for version in project['versions']:
|
188 |
-
# Force published to be boolean
|
189 |
-
if 'published' in version:
|
190 |
-
version['published'] = bool(version['published'])
|
191 |
-
if 'deleted' in version:
|
192 |
-
version['deleted'] = bool(version['deleted'])
|
193 |
-
|
194 |
# Check for race condition
|
195 |
if config.last_update_date and current_config.last_update_date:
|
196 |
if not timestamps_equal(config.last_update_date, current_config.last_update_date):
|
@@ -644,17 +615,10 @@ class ConfigProvider:
|
|
644 |
version = next((v for v in project.versions if v.no == version_no), None)
|
645 |
if not version:
|
646 |
raise ResourceNotFoundError("version", version_no)
|
647 |
-
|
648 |
-
# Debug: Log version published status
|
649 |
-
log_debug(f"π Updating version {version_no} - published: {version.published}, type: {type(version.published)}")
|
650 |
-
|
651 |
# Ensure published is a boolean (safety check)
|
652 |
if version.published is None:
|
653 |
version.published = False
|
654 |
-
|
655 |
-
# Convert to boolean if it's a string
|
656 |
-
if isinstance(version.published, str):
|
657 |
-
version.published = version.published.lower() == 'true'
|
658 |
|
659 |
# Published versions cannot be edited
|
660 |
if version.published:
|
|
|
77 |
if 'projects' in config_data and len(config_data['projects']) > 0:
|
78 |
first_project = config_data['projects'][0]
|
79 |
log_debug(f"π Raw project data - last_update_date: {first_project.get('last_update_date')}")
|
|
|
|
|
|
|
|
|
|
|
|
|
80 |
|
81 |
# Ensure required fields
|
82 |
if 'config' not in config_data:
|
|
|
85 |
# Parse API configs (handle JSON strings)
|
86 |
if 'apis' in config_data:
|
87 |
cls._parse_api_configs(config_data['apis'])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
|
89 |
# Validate and create model
|
90 |
cfg = ServiceConfig.model_validate(config_data)
|
|
|
161 |
# Load current config for race condition check
|
162 |
try:
|
163 |
current_config = cls._load()
|
164 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
165 |
# Check for race condition
|
166 |
if config.last_update_date and current_config.last_update_date:
|
167 |
if not timestamps_equal(config.last_update_date, current_config.last_update_date):
|
|
|
615 |
version = next((v for v in project.versions if v.no == version_no), None)
|
616 |
if not version:
|
617 |
raise ResourceNotFoundError("version", version_no)
|
618 |
+
|
|
|
|
|
|
|
619 |
# Ensure published is a boolean (safety check)
|
620 |
if version.published is None:
|
621 |
version.published = False
|
|
|
|
|
|
|
|
|
622 |
|
623 |
# Published versions cannot be edited
|
624 |
if version.published:
|