Skip to content

Adds description field in variable (#12413) #15194

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

Merged
merged 6 commits into from
Apr 12, 2021

Conversation

itroulli
Copy link
Contributor

@itroulli itroulli commented Apr 4, 2021

Closes #12413

This is my first PR. I tried to follow the CONTRIBUTING guide step by step. It passed all the pre-commit tests.

My PR adds a description field for the Airflow variables that can only be set and seen trhough the UI. Also, I would prefer to have created a textarea class instead of an input class but I wasn't able to find a way to do it. Any advice on that will be appreciated.


^ 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 UPDATING.md.

@boring-cyborg boring-cyborg bot added the area:webserver Webserver related Issues label Apr 4, 2021
@boring-cyborg
Copy link

boring-cyborg bot commented Apr 4, 2021

Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contribution Guide (https://github.com/apache/airflow/blob/master/CONTRIBUTING.rst)
Here are some useful points:

  • Pay attention to the quality of your code (flake8, pylint and type annotations). Our pre-commits will help you with that.
  • In case of a new feature add useful documentation (in docstrings or in docs/ directory). Adding a new operator? Check this short guide Consider adding an example DAG that shows how users should use it.
  • Consider using Breeze environment for testing locally, it’s a heavy docker but it ships with a working Airflow and a lot of integrations.
  • Be patient and persistent. It might take some time to get a review or get the final approval from Committers.
  • Please follow ASF Code of Conduct for all communication including (but not limited to) comments on Pull Requests, Mailing list and Slack.
  • Be sure to read the Airflow Coding style.
    Apache Airflow is a community-driven project and together we are making it better 🚀.
    In case of doubts contact the developers at:
    Mailing List: dev@airflow.apache.org
    Slack: https://s.apache.org/airflow-slack

@kurtqq
Copy link
Contributor

kurtqq commented Apr 5, 2021

thanks @itroulli !

@itroulli
Copy link
Contributor Author

itroulli commented Apr 6, 2021

Thank you @kurtqq for the guidance! If you have any suggestion on how to make the field a textarea one, let me know!

Copy link
Contributor

@xinbinhuang xinbinhuang left a comment

Choose a reason for hiding this comment

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

LGTM

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

github-actions bot commented Apr 9, 2021

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 master at your convenience, or amend the last commit of the PR, and push it with --force-with-lease.

@xinbinhuang xinbinhuang self-requested a review April 9, 2021 06:43
@xinbinhuang xinbinhuang self-requested a review April 9, 2021 06:55
@xinbinhuang xinbinhuang force-pushed the issue_12413 branch 2 times, most recently from bf7fa19 to d97e70d Compare April 9, 2021 19:33
@xinbinhuang
Copy link
Contributor

xinbinhuang commented Apr 9, 2021

@itroulli I help rebase the branch because any changes in the migration folder require to rebase on the latest master before merging. Once CI passed, I will merge it

@itroulli
Copy link
Contributor Author

itroulli commented Apr 9, 2021

@itroulli I help rebase the branch because any changes in the migration folder require to rebase on the latest master before merging. Once CI passed, I will merge it

Thanks a lot for the help! I appreciate it!

@@ -47,12 +47,14 @@ class Variable(Base, LoggingMixin):
id = Column(Integer, primary_key=True)
key = Column(String(ID_LEN), unique=True)
_val = Column('val', Text)
description = Column(Text(5000))
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
description = Column(Text(5000))
description = Column(Text)

@itroulli sorry for the confusion. Postgres doesn't allow modifier on text field. Can you also update this and the alembic migration file? (you would need to git pull the branch first) Let me know if you have any questions :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think I'd need some help with updating the revision keys in the migration file. I believe this is why some checks are failing. With Python 3.6, MySQL 5.7 right now I get this error:
alembic.util.exc.CommandError: Can't locate revision identified by '458c2838cbca'

Copy link
Contributor

@xinbinhuang xinbinhuang Apr 11, 2021

Choose a reason for hiding this comment

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

Hmm, this is because there are other migration changes merged to the master before you, which happens sometimes given the number of PRs we have. We used to have problems with multiple diverge alembic heads, and we mitigate it by making sure that any PR affecting the migration folder will need to rebase on the latest master. So, to fix it, I normally delete the revision file and regenerate it after rebase to master

Copy link
Contributor

Choose a reason for hiding this comment

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

This is the most recent change #15203

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Seems that everything is passing now! :)

@xinbinhuang xinbinhuang self-requested a review April 9, 2021 22:10
@github-actions
Copy link

The Workflow run is cancelling this PR. It has some failed jobs matching ^Pylint$,^Static checks,^Build docs$,^Spell check docs$,^Provider packages,^Checks: Helm tests$,^Test OpenAPI*.

@github-actions
Copy link

The Workflow run is cancelling this PR. It has some failed jobs matching ^Pylint$,^Static checks,^Build docs$,^Spell check docs$,^Provider packages,^Checks: Helm tests$,^Test OpenAPI*.

@github-actions
Copy link

The Workflow run is cancelling this PR. It has some failed jobs matching ^Pylint$,^Static checks,^Build docs$,^Spell check docs$,^Provider packages,^Checks: Helm tests$,^Test OpenAPI*.

Ilias Troullinos and others added 2 commits April 12, 2021 00:15
@xinbinhuang xinbinhuang merged commit 925ef28 into apache:master Apr 12, 2021
@boring-cyborg
Copy link

boring-cyborg bot commented Apr 12, 2021

Awesome work, congrats on your first merged pull request!

@xinbinhuang
Copy link
Contributor

@itroulli Thank you so much for the PR!

@ashb ashb added this to the Airflow 2.1 milestone Apr 12, 2021
Comment on lines +53 to +57
def __init__(self, key=None, val=None, description=None):
super().__init__()
self.key = key
self.val = val
self.description = description
Copy link
Member

Choose a reason for hiding this comment

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

Can we add some tests for this feature please

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kaxil Since this is a feature only viewable/editable from the UI, what tests would you suggest? Just including the description field in this line would suffice?
Thanks in advance!

Copy link
Member

Choose a reason for hiding this comment

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

Probably just a separate test in that file, the simply tests that you can set description to a variable, which is peristed to db and when you do Variable.get you get the same description field

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kaxil The thing is that following @kurtqq 's suggestion in the issue, I didn't modify the Variable.get method so it won't return the description.

I may be missing something though, let me know what do you think.

Copy link
Member

Choose a reason for hiding this comment

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

That is debatable :) -- but anyways for now you could just do session.query(Variable.key, Variable.description).first() and just verify that

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks a lot for the tips! I rebased, implemented it and pushed in my branch but I guess a new PR is needed, right?

Copy link
Member

Choose a reason for hiding this comment

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

Yup : )

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've created #15400. Thanks again!

kaxil pushed a commit that referenced this pull request Apr 16, 2021
Related: #15194

In continuation of PR #15194, I've added a test for the description field of the variable.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:webserver Webserver related Issues full tests needed We need to run full set of tests for this PR to merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Description Field for Variables
5 participants