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

Improve documentation on Params #20567

Merged
merged 12 commits into from
Jan 4, 2022
Merged

Conversation

MatrixManAtYrService
Copy link
Contributor

I think that this doc could be improved by adding examples of how to reference the params in your dag. (Also, the current example code causes this: #20559.)

While trying to find the right place to work a few reference examples in, I ended up rewriting quite a lot of it.
Let me know if you think that this is an improvement.

I haven't yet figured out how to build this and view it locally, and I'd want to do that as a sanity check before merging it, but I figured get feedback on what I've written before I do that.

@potiuk
Copy link
Member

potiuk commented Dec 29, 2021

I haven't yet figured out how to build this and view it locally, and I'd want to do that as a sanity check before merging it, but I figured get feedback on what I've written before I do that.

./breeze build-docs -- --package-filter apache-airflow

Then ./docs/start_doc_server.sh

You will also see result of building the docs here in CI .

More info here: https://github.com/apache/airflow/blob/main/docs/README.rst

@potiuk
Copy link
Member

potiuk commented Dec 30, 2021

That looks good to me but you need to fix static checks and docs builds .

For static checks pre-commit is your friend :)

@kaxil
Copy link
Member

kaxil commented Dec 30, 2021

Static check failure looks unrelated, but the doc failure is related.

Do rebase on main and build docs again


.. code-block::
:caption a simple DAG with a parameter
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
:caption a simple DAG with a parameter
:caption: a simple DAG with a parameter

Check: https://www.sphinx-doc.org/en/1.4.9/markup/code.html#caption-and-name

If there's already a dag param with that name, the task-level default will take precedence over the dag-level default.

.. code-block::
:caption tasks can have parameters too
Copy link
Member

Choose a reason for hiding this comment

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

Same here

If templates aren't your style, you can access params in via the context.

.. code-block::
:caption use the context kwarg
Copy link
Member

Choose a reason for hiding this comment

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

and here

@MatrixManAtYrService
Copy link
Contributor Author

MatrixManAtYrService commented Dec 31, 2021

Thanks for the tips @potiuk

When I do that (on Ubuntu 20.04, in a fresh venv) I get some errors:

#################### Running docs building ####################

apache-airflow : Building documentation
apache-airflow : Running sphinx. The output is hidden until an error occurs.
apache-airflow : Finished docs building with errors
#################### Output for documentation build apache-airflow ####################

apache-airflow : ################################################################################
apache-airflow  [01mRunning Sphinx v3.4.3[39;49;00m
apache-airflow
apache-airflow  Traceback (most recent call last):
apache-airflow    File "/usr/local/lib/python3.8/site-packages/sphinx/registry.py", line 417, in load_extension
apache-airflow      mod = import_module(extname)
apache-airflow    File "/usr/local/lib/python3.8/importlib/__init__.py", line 127, in import_module
apache-airflow      return _bootstrap._gcd_import(name, package, level)
apache-airflow    File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
apache-airflow    File "<frozen importlib._bootstrap>", line 991, in _find_and_load
apache-airflow    File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
apache-airflow    File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
apache-airflow    File "<frozen importlib._bootstrap_external>", line 843, in exec_module
apache-airflow    File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
apache-airflow    File "/opt/airflow/docs/exts/exampleinclude.py", line 31, in <module>
apache-airflow      from sphinx.ext.viewcode import viewcode_anchor
apache-airflow  ImportError: cannot import name 'viewcode_anchor' from 'sphinx.ext.viewcode' (/usr/local/lib/python3.8/site-packages/sphinx/ext/viewcode.py)
apache-airflow
apache-airflow The above exception was the direct cause of the following exception:
apache-airflow
apache-airflow Traceback (most recent call last):
apache-airflow   File "/usr/local/lib/python3.8/site-packages/sphinx/cmd/build.py", line 276, in build_main
apache-airflow     app = Sphinx(args.sourcedir, args.confdir, args.outputdir,
apache-airflow   File "/usr/local/lib/python3.8/site-packages/sphinx/application.py", line 245, in __init__
apache-airflow     self.setup_extension(extension)
apache-airflow   File "/usr/local/lib/python3.8/site-packages/sphinx/application.py", line 402, in setup_extension
apache-airflow     self.registry.load_extension(self, extname)
apache-airflow   File "/usr/local/lib/python3.8/site-packages/sphinx/registry.py", line 420, in load_extension
apache-airflow     raise ExtensionError(__('Could not import extension %s') % extname,
apache-airflow sphinx.errors.ExtensionError: Could not import extension exampleinclude (exception: cannot import name
'viewcode_anchor' from 'sphinx.ext.viewcode' (/usr/local/lib/python3.8/site-packages/sphinx/ext/viewcode.py))
apache-airflow
apache-airflow  [91mExtension error:[39;49;00m
apache-airflow  Could not import extension exampleinclude (exception: cannot import name 'viewcode_anchor' from 'sphinx.ext.viewcode'
(/usr/local/lib/python3.8/site-packages/sphinx/ext/viewcode.py))

After which I can run the server, but I see a 404 error when I navigate here http://localhost:8000/docs/apache-airflow/latest/index.html

It seems to work OK on my Macbook though, so I'll just use that for now (though I'm happy to help toubleshoot the above error if you'd like, I'm just not sure where to start).

@potiuk
Copy link
Member

potiuk commented Dec 31, 2021

When I do that (on Ubuntu 20.04, in a fresh venv) I get some errors:

Did you run this?

./breeze build-docs -- --package-filter apache-airflow

If so - make sure to pull&build the image when asked.

@MatrixManAtYrService
Copy link
Contributor Author

I don't know how I overlooked that prompt (several times). It's working now, thanks.

@eladkal eladkal self-requested a review December 31, 2021 20:52
@MatrixManAtYrService
Copy link
Contributor Author

I think I should've made this a draft PR until I was ready. Sorry about the extra noise.

Anyhow, I think that it is now actually ready for a review.

Copy link
Member

@kaxil kaxil left a comment

Choose a reason for hiding this comment

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

Awesome, well done @MatrixManAtYrService 🎉

@github-actions github-actions bot added the okay to merge It's ok to merge this PR as it does not require more tests label Jan 4, 2022
@github-actions
Copy link

github-actions bot commented Jan 4, 2022

The PR is likely ready to be merged. No tests are needed as no important environment files, nor python files were modified by it. However, committers might decide that full test matrix is needed and add the 'full tests needed' label. Then you should rebase it to the latest main or amend the last commit of the PR, and push it with --force-with-lease.

@kaxil kaxil changed the title params concept doc rework Improve documentation on Params Jan 4, 2022
@kaxil kaxil merged commit 064efbe into apache:main Jan 4, 2022
@MatrixManAtYrService MatrixManAtYrService deleted the params_docs branch January 4, 2022 04:19
potiuk pushed a commit that referenced this pull request Jan 23, 2022
I think that this doc could be improved by adding examples of how to reference the params in your dag. (Also, the current example code causes this: #20559.)

While trying to find the right place to work a few reference examples in, I ended up rewriting quite a lot of it.
Let me know if you think that this is an improvement.

I haven't yet figured out how to build this and view it locally, and I'd want to do that as a sanity check before merging it, but I figured get feedback on what I've written before I do that.

(cherry picked from commit 064efbe)
@potiuk potiuk added the type:doc-only Changelog: Doc Only label Jan 23, 2022
@potiuk potiuk added this to the Airflow 2.2.4 milestone Jan 23, 2022
jedcunningham pushed a commit that referenced this pull request Jan 27, 2022
I think that this doc could be improved by adding examples of how to reference the params in your dag. (Also, the current example code causes this: #20559.)

While trying to find the right place to work a few reference examples in, I ended up rewriting quite a lot of it.
Let me know if you think that this is an improvement.

I haven't yet figured out how to build this and view it locally, and I'd want to do that as a sanity check before merging it, but I figured get feedback on what I've written before I do that.

(cherry picked from commit 064efbe)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:documentation okay to merge It's ok to merge this PR as it does not require more tests type:doc-only Changelog: Doc Only
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants