Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix links to sources for examples #24386

Merged
merged 1 commit into from
Jun 13, 2022

Conversation

potiuk
Copy link
Member

@potiuk potiuk commented Jun 10, 2022

The links to example sources in exampleinclude have been broken in a
number of providers and they were additionally broken by AIP-47.

This PR fixes it.

Fixes: #23632
Fixes: apache/airflow-site#536


^ Add meaningful description above

Read the Pull Request Guidelines for more information.
In case of fundamental code change, Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragement file, named {pr_number}.significant.rst, in newsfragments.

@boring-cyborg boring-cyborg bot added provider:cncf-kubernetes Kubernetes provider related issues area:providers kind:documentation provider:Apache provider:amazon-aws AWS/Amazon - related issues provider:google Google (including GCP) related issues labels Jun 10, 2022
@potiuk potiuk requested a review from josh-fell June 10, 2022 22:05
@potiuk
Copy link
Member Author

potiuk commented Jun 10, 2022

CC: @josh-fell - another fix to links for AIP-47

Screenshot 2022-06-11 at 00 07 11

vs.

Screenshot 2022-06-11 at 00 12 09

I think fixed past broken links will be difficult - because we would have to regenerate a lot of the class "apis" which were excluded (mistakenly) but I have an idea how we can instead utilise links to github and post-process links in the generated documenation (very similar to the fix merged yesterday)

@potiuk potiuk force-pushed the fix-source-links-in-examples branch from 22d66f6 to ed85209 Compare June 10, 2022 22:15
@potiuk
Copy link
Member Author

potiuk commented Jun 10, 2022

cc: @rbiegacz

@potiuk potiuk force-pushed the fix-source-links-in-examples branch from ed85209 to 414825d Compare June 10, 2022 22:18
@potiuk
Copy link
Member Author

potiuk commented Jun 10, 2022

@mik-laj - finally got some time to take a look and It looks I managed to fix it :)

@potiuk
Copy link
Member Author

potiuk commented Jun 11, 2022

@mik-laj :) ?

@potiuk potiuk force-pushed the fix-source-links-in-examples branch from 414825d to 278cc7f Compare June 12, 2022 10:45
@potiuk potiuk requested a review from ashb as a code owner June 12, 2022 10:45
@potiuk potiuk requested a review from eladkal June 12, 2022 10:48
@potiuk potiuk force-pushed the fix-source-links-in-examples branch from 278cc7f to 060f78d Compare June 12, 2022 12:30
@potiuk
Copy link
Member Author

potiuk commented Jun 12, 2022

I also excluded docs from the "no relative imports rule" and converted the imports there to be relative in order to make "docs building utils" work fine with scripts and flake/isort without having to do some "noqa: excludes" @mik-laj.

@potiuk potiuk force-pushed the fix-source-links-in-examples branch from 060f78d to 2e76e27 Compare June 12, 2022 13:44
docs/__init__.py Show resolved Hide resolved
@@ -33,6 +33,7 @@ Content
:caption: References

Python API <_api/airflow/providers/apache/cassandra/index>
System Tests <_api/tests/system/providers/apache/cassandra/index>
Copy link
Member

Choose a reason for hiding this comment

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

Why are we linking to this from user facing docs? That seems to me like a very odd thing to do.

In other words: I can't think of any reason why a user would ever visit and git anything useful from this page.

Copy link
Member Author

@potiuk potiuk Jun 13, 2022

Choose a reason for hiding this comment

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

Yes I also thought we might not need that. It's Mainly there add it to any toc tree- if we don't do it, sphinx complains that the index is missing from the toc tree. Do you know how to exclude those links in general? I am happy to remove them, but I simply have no idea how. Likely some exclude somewhere in sphinx config.

Previously example dags were excluded by */example_dags/* and that's why it was not needed but with the latest sphinx update it caused hte problem of missing examples. We cannot exclude them this way because then they will be removed from the generated html (that was precisely the root cause of missing links previously - the "missing index in toc tree" was not generated but also link to example dags led to 404 because the generated example_dags pages were missing.

So if we know a better way to keep the files but not to have them included in any toc tree - that would be awesome. But I do no know how to do it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok I think I found a way.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

This would be too easy.

But I am close to get it (and I also found some index inconsistencies that I am also fixing).

Copy link
Member Author

Choose a reason for hiding this comment

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

FYI. @ashb The main problem was that :hidden: in toc tree did not remove the sidebar link. And I found out in the theme we can disable sidebar links for hidden TOC, but we were already using this in "apache-airfow" and "chart" (but luckily only there) to show sidebar content while not showing TOC in the page.

Now we have hidden links shown in the sidebar in Airflow:

image

And no "system tests" links in provider's - neither sidebar, nor main page:

image

But the sources are there.

Both for legacy exmple dags:

image

And for new system tests:

image

Also we have consistent "example dags" links

Wasn't THAT straightforward :). But finally seems to be there.

I also found a few inconsistencies in provider indexes that I fixed. The system tests for google providers were moved without sub-folders (which was wrong).

The __init__.py works nicely for docs scripts too. While enabling relative imports in "docs" I managed to make it in the way that:

  • no need to insert syspath before imports
  • build_docs.py ./publish_docs.py still works with shebang as executables and you can run it either with local airflow venv or in breeze for repeatability
  • isort behaviour is consistent no matter if you only modify docs/* python files or run pre-commit for --all-files
  • we have no implicit package in docs.

I also double-checked that adding init.py in docs did not mess with the airflow package (which I was afraid that could be side effect:

⌂85% θ92° [jarek:~/code/airflow] [airflow-3.7] fix-source-links-in-examples(+15/-1)+ 41s ± unzip -t dist/apache_airflow-2.4.0.dev0-py3-none-any.whl| grep doc
    testing: airflow/contrib/operators/docker_swarm_operator.py   OK
    testing: airflow/hooks/docker_hook.py   OK
    testing: airflow/operators/docker_operator.py   OK
    testing: airflow/providers/docker/__init__.py   OK
    testing: airflow/providers/docker/decorators/__init__.py   OK
    testing: airflow/providers/docker/decorators/docker.py   OK
    testing: airflow/providers/docker/hooks/__init__.py   OK
    testing: airflow/providers/docker/hooks/docker.py   OK
    testing: airflow/providers/docker/operators/__init__.py   OK
    testing: airflow/providers/docker/operators/docker.py   OK
    testing: airflow/providers/docker/operators/docker_swarm.py   OK
    testing: airflow/utils/docs.py    OK
    testing: airflow/www/static/dist/redoc.standalone.js   OK
    testing: airflow/www/static/dist/redoc.standalone.js.LICENSE.txt   OK
    testing: airflow/www/static/dist/redoc.standalone.js.map   OK
    testing: airflow/www/templates/airflow/redoc.html   OK
    testing: airflow/www/templates/appbuilder/dag_docs.html   OK

Copy link
Member Author

Choose a reason for hiding this comment

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

eeechhh. Bash operator is still not there :(

@potiuk potiuk force-pushed the fix-source-links-in-examples branch 3 times, most recently from 928c91e to 742cf81 Compare June 13, 2022 16:55
@potiuk
Copy link
Member Author

potiuk commented Jun 13, 2022

Hell yeah! I THINK ALL IS GOOD!

image

@potiuk potiuk requested a review from ashb June 13, 2022 16:56
Comment on lines +691 to +693
'**/example_sla_dag.py',
'**/example_taskflow_api_etl_docker_virtualenv.py',
'**/example_dag_decorator.py',
Copy link
Member

Choose a reason for hiding this comment

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

These files had problems/not used, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

I can try to remove those and see. :)

Copy link
Member Author

Choose a reason for hiding this comment

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

Pretty cryptic:

============================== apache-airflow ==============================
------------------------------ Error   1 --------------------
WARNING: Unknown type: placeholder

------------------------------ Error   2 --------------------
WARNING: Unknown type: placeholder

When I remove them. I will leave to the next poor soul that will start thinking that fixing docs building MUST be easy.

@github-actions github-actions bot added the full tests needed We need to run full set of tests for this PR to merge label Jun 13, 2022
@github-actions
Copy link

The PR most likely needs to run full matrix of tests because it modifies parts of the core of Airflow. However, committers might decide to merge it quickly and take the risk. If they don't merge it quickly - please rebase it to the latest main at your convenience, or amend the last commit of the PR, and push it with --force-with-lease.

The links to example sources in exampleinclude have been broken in a
number of providers and they were additionally broken by AIP-47.

This PR fixes it.

Fixes: apache#23632
Fixes: apache/airflow-site#536
@potiuk potiuk force-pushed the fix-source-links-in-examples branch from 742cf81 to e3745cc Compare June 13, 2022 17:38
@potiuk potiuk merged commit 08b675c into apache:main Jun 13, 2022
@potiuk potiuk deleted the fix-source-links-in-examples branch June 13, 2022 17:38
@potiuk
Copy link
Member Author

potiuk commented Jun 13, 2022

Merging quickly to fix docs-buiild error introduced in #24413 - it built except that doc error

potiuk added a commit to potiuk/airflow that referenced this pull request Jun 29, 2022
The links to example sources in exampleinclude have been broken in a
number of providers and they were additionally broken by AIP-47.

This PR fixes it.

Fixes: apache#23632
Fixes: apache/airflow-site#536
(cherry picked from commit 08b675c)
@ephraimbuddy ephraimbuddy added this to the Airflow 2.3.3 milestone Jun 30, 2022
@ephraimbuddy ephraimbuddy added the changelog:skip Changes that should be skipped from the changelog (CI, tests, etc..) label Jun 30, 2022
@ephraimbuddy ephraimbuddy added type:bug-fix Changelog: Bug Fixes and removed changelog:skip Changes that should be skipped from the changelog (CI, tests, etc..) labels Jul 1, 2022
potiuk added a commit to potiuk/airflow that referenced this pull request Aug 4, 2022
The problem (fixed in apache#24386) with broken links was that
the autoapi-generated source html were either exluded
(via example_dags/** exclusion) or not included (system_tests)
when the documentation was generated.

We cannot easily re-add and regenerated all those autoapi sources
so instead the fix is to replace all the links to autoapi sources
with corresponding links to raw github sources. We can easily do
that using tags of providers and link to specific tagged versions
of those example dags and this is the best we can do now.

The apache#24386 brings back linking to autoapi-generated html pages.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:providers full tests needed We need to run full set of tests for this PR to merge kind:documentation provider:amazon-aws AWS/Amazon - related issues provider:cncf-kubernetes Kubernetes provider related issues provider:google Google (including GCP) related issues type:bug-fix Changelog: Bug Fixes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Broken Source Code Links in Operator Guides Links to provider example dags are broken
4 participants