Skip to content

fix(DATAGO-125814): implement lazy imports to improve CLI startup performance#1087

Open
cyrus2281 wants to merge 2 commits intomainfrom
cyrus/DATAGO-125814/cli-speed
Open

fix(DATAGO-125814): implement lazy imports to improve CLI startup performance#1087
cyrus2281 wants to merge 2 commits intomainfrom
cyrus/DATAGO-125814/cli-speed

Conversation

@cyrus2281
Copy link
Collaborator

What is the purpose of this change?

This change improves the CLI startup performance by implementing lazy imports, ensuring that heavy dependencies like Flask and SQLAlchemy are only loaded when actually needed rather than at startup time.

How was this change implemented?

  • fix: implement lazy imports to improve CLI startup performance
    • Moved imports of Flask, SQLAlchemy, and other heavy dependencies inside the functions that use them
    • Implemented lazy imports in web configuration portal modules
    • Made imports in run, eval, and tools commands load only when the command is executed
    • Enhanced version display to show enterprise package version when installed

Key Design Decisions

Lazy importing was chosen as a lightweight solution to improve CLI responsiveness without restructuring the codebase. This approach provides immediate performance benefits while maintaining backward compatibility and requiring minimal code changes.

How was this change tested?

  • Manual testing: CLI startup time before and after changes
  • Unit tests: Updated version display tests to verify enterprise version detection
  • Integration tests: N/A
  • Known limitations: Could affect error reporting if imports fail at runtime instead of startup

Is there anything the reviewers should focus on/be aware of?

Reviewers should check that error handling is appropriate when imports fail at runtime rather than startup.

Copy link
Collaborator

@RohanSreelesh RohanSreelesh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LG

@cyrus2281 cyrus2281 enabled auto-merge (squash) February 27, 2026 19:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants