MCPcopy Create free account
hub / github.com/SkyworkAI/DeepResearchAgent / load_from_json

Method load_from_json

src/version/server.py:290–335  ·  view source on GitHub ↗

Load version histories from JSON Args: file_path: File path to load from Returns: True if loaded successfully, False otherwise

(self, file_path: Optional[str] = None)

Source from the content-addressed store, hash-verified

288 return str(file_path)
289
290 async def load_from_json(self, file_path: Optional[str] = None) -> bool:
291 """Load version histories from JSON
292
293 Args:
294 file_path: File path to load from
295
296 Returns:
297 True if loaded successfully, False otherwise
298 """
299 file_path = file_path if file_path is not None else self.save_path
300
301 async with file_lock(file_path):
302 if not os.path.exists(file_path):
303 logger.warning(f"| ⚠️ Version file not found: {file_path}")
304 return False
305
306 try:
307 with open(file_path, "r", encoding="utf-8") as f:
308 load_data = json.load(f)
309
310 # Clear existing histories
311 for component_type in self._version_histories:
312 self._version_histories[component_type].clear()
313
314 # Load histories
315 component_types = load_data.get("component_type", {})
316 for component_type, histories in component_types.items():
317 if component_type not in self._version_histories:
318 logger.warning(f"| ⚠️ Unknown component type: {component_type}")
319 continue
320
321 for name, history_dict in histories.items():
322 try:
323 # Reconstruct ComponentVersionHistory
324 version_history = ComponentVersionHistory(**history_dict)
325 self._version_histories[component_type][name] = version_history
326 except Exception as e:
327 logger.error(f"| ❌ Failed to load version history for {name}: {e}")
328 continue
329
330 logger.info(f"| 📂 Loaded version histories from {file_path}")
331 return True
332
333 except Exception as e:
334 logger.error(f"| ❌ Failed to load version data from {file_path}: {e}")
335 return False
336
337 @staticmethod
338 def compare_versions(v1: str, v2: str) -> int:

Callers

nothing calls this directly

Calls 8

warningMethod · 0.80
existsMethod · 0.45
loadMethod · 0.45
clearMethod · 0.45
getMethod · 0.45
errorMethod · 0.45
infoMethod · 0.45

Tested by

no test coverage detected