Skip to content

Use lazy import for generate_mapping_docs by moving it in setup function #2188

Closed
pankajastro wants to merge 2 commits into
mainfrom
fix_docs_job
Closed

Use lazy import for generate_mapping_docs by moving it in setup function #2188
pankajastro wants to merge 2 commits into
mainfrom
fix_docs_job

Conversation

@pankajastro
Copy link
Copy Markdown
Contributor

@pankajastro pankajastro commented Dec 8, 2025

@pankajastro pankajastro changed the title Use lazy import for moving generate_mapping_docs by moving it in function setup Use lazy import for generate_mapping_docs by moving it in function setup Dec 8, 2025
@pankajastro pankajastro changed the title Use lazy import for generate_mapping_docs by moving it in function setup Use lazy import for generate_mapping_docs by moving it in setup function Dec 8, 2025
@codecov
Copy link
Copy Markdown

codecov Bot commented Dec 8, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.84%. Comparing base (b8f77b3) to head (1ba5a30).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2188      +/-   ##
==========================================
+ Coverage   97.46%   97.84%   +0.38%     
==========================================
  Files          94       94              
  Lines        6038     6038              
==========================================
+ Hits         5885     5908      +23     
+ Misses        153      130      -23     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@pankajastro pankajastro marked this pull request as ready for review December 8, 2025 12:07
Copilot AI review requested due to automatic review settings December 8, 2025 12:07
@pankajastro pankajastro marked this pull request as draft December 8, 2025 12:08
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR improves the documentation build process by converting the generate_mapping_docs import from an eager top-level import to a lazy import within a Sphinx setup function. This change allows the documentation to build gracefully even when Airflow dependencies are not installed, making local development easier.

Key Changes:

  • Moved generate_mapping_docs import and execution from module-level to inside a Sphinx setup function
  • Added error handling to catch and warn about missing dependencies instead of failing the build
  • Made the paths explicit by constructing absolute paths to templates and output directories

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread docs/conf.py
"Make sure Airflow is installed (pip install -r docs/requirements.txt). "
"Documentation will be built without profile mapping pages.",
UserWarning,
)
Copy link

Copilot AI Dec 8, 2025

Choose a reason for hiding this comment

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

The Sphinx setup function should return a metadata dictionary. This is a best practice that helps Sphinx understand the extension's requirements and capabilities. Consider adding a return statement at the end:

return {
    'version': '0.1',
    'parallel_read_safe': True,
    'parallel_write_safe': True,
}
Suggested change
)
)
return {
'version': '0.1',
'parallel_read_safe': True,
'parallel_write_safe': True,
}

Copilot uses AI. Check for mistakes.
Comment thread docs/conf.py
Comment on lines +69 to +75
# If Airflow is not available, skip generating mapping docs
# This can happen during local development if dependencies aren't installed
import warnings

warnings.warn(
f"Could not generate mapping docs: {e}. "
"Make sure Airflow is installed (pip install -r docs/requirements.txt). "
Copy link

Copilot AI Dec 8, 2025

Choose a reason for hiding this comment

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

The error message says "If Airflow is not available" but the actual import is from docs.generate_mappings. The import could fail for reasons other than Airflow not being available (e.g., missing jinja2). Consider making the error message more accurate:

# If dependencies are not available, skip generating mapping docs
# This can happen during local development if dependencies aren't fully installed
Suggested change
# If Airflow is not available, skip generating mapping docs
# This can happen during local development if dependencies aren't installed
import warnings
warnings.warn(
f"Could not generate mapping docs: {e}. "
"Make sure Airflow is installed (pip install -r docs/requirements.txt). "
# If required dependencies are not available, skip generating mapping docs
# This can happen during local development if all documentation dependencies aren't installed
import warnings
warnings.warn(
f"Could not generate mapping docs: {e}. "
"Make sure all documentation dependencies are installed (pip install -r docs/requirements.txt). "

Copilot uses AI. Check for mistakes.
@pankajastro
Copy link
Copy Markdown
Contributor Author

The CI is green now, so we do not need this

@pankajastro pankajastro closed this Dec 8, 2025
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.

2 participants