Skip to content

Conversation

@VinayGb665
Copy link
Contributor

@VinayGb665 VinayGb665 commented Jun 22, 2020


Adding a yaml file parser to LocalFilesystemBackend, structure would be similar to that of earlier JSON found here and here

Closes : #9417

Make sure to mark the boxes below before creating PR: [x]

  • Description above provides context of the change
  • Unit tests coverage for changes (not needed for documentation changes)
  • Target Github ISSUE in description if exists
  • Commits follow "How to write a good git commit message"
  • Relevant documentation is updated including usage instructions.
  • I will engage committers as explained in Contribution Workflow Example.

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.
Read the Pull Request Guidelines for more information.
@wip ready for review

@boring-cyborg
Copy link

boring-cyborg bot commented Jun 22, 2020

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: [email protected]
    Slack: https://apache-airflow-slack.herokuapp.com/

@mik-laj
Copy link
Member

mik-laj commented Jun 22, 2020

Can you also update docs?

@VinayGb665 VinayGb665 changed the title [WIP] YAML file format in LocalFilesystemBackend YAML file format in LocalFilesystemBackend Jun 23, 2020
@VinayGb665 VinayGb665 changed the title YAML file format in LocalFilesystemBackend [WIP] YAML file format in LocalFilesystemBackend Jun 23, 2020

.. code-block:: yaml
CONN_A: 'mysq://host_a'
Copy link
Member

Choose a reason for hiding this comment

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

Can you use these examples in tests? This will facilitate verification that everything is okay.

(
({}, {}),
({"KEY": "AAA"}, {"KEY": "AAA"}),
({"KEY_A": "AAA", "KEY_B": "BBB"}, {"KEY_A": "AAA", "KEY_B": "BBB"}),
Copy link
Member

Choose a reason for hiding this comment

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

Can you use YAML file here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added YAML files for both variables and connection tests

return {}, [FileSyntaxError(line_no=1, message="The file is empty.")]
try:
secrets = yaml.safe_load(content)
except yaml.YAMLError as e:
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
except yaml.YAMLError as e:
except yaml.MarkedYAMLError as e:
return {}, [FileSyntaxError(line_no=e.context_mark.line, message=str(e))]
except yaml.YAMLError as e:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

Copy link
Member

@mik-laj mik-laj left a comment

Choose a reason for hiding this comment

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

I really like this change. Editing JSON files was tiring.

@VinayGb665 VinayGb665 requested a review from mik-laj June 25, 2020 15:07
@mik-laj
Copy link
Member

mik-laj commented Jun 25, 2020

Is this still a WIP? Should I go further?

@VinayGb665
Copy link
Contributor Author

Is this still a WIP? Should I go further?

Nope not a WIP. Ill update the title. Please you can go further

@mik-laj mik-laj changed the title [WIP] YAML file format in LocalFilesystemBackend YAML file format in LocalFilesystemBackend Jun 26, 2020
@mik-laj mik-laj merged commit e7dff68 into apache:master Jun 26, 2020
@boring-cyborg
Copy link

boring-cyborg bot commented Jun 26, 2020

Awesome work, congrats on your first merged pull request!

@mik-laj
Copy link
Member

mik-laj commented Jun 26, 2020

@VinayGb665 Thank you very much. What next? 🐈

@VinayGb665
Copy link
Contributor Author

Looking forward to contribute more.
If you have any tickets in mind please suggest 😄 .

@mik-laj
Copy link
Member

mik-laj commented Jun 26, 2020

Could you add support for the extra parameter without using nested JSON?
I am currently thinking about something like this.

conn_c:
   conn_type: scheme
   host: host
   extra_dejson:
       extra__google_cloud_platform__keyfile_dict: AAA

Currently, the extra parameter can only be defined as follows.

conn_c:
   conn_type: scheme
   host: host
   extra_dejson: {"extra__google_cloud_platform__keyfile_dict": "file_content"}

It works, but it's not perfect.

@VinayGb665
Copy link
Contributor Author

VinayGb665 commented Jun 26, 2020

Could you add support for the extra parameter without using nested JSON?
I am currently thinking about something like this.

conn_c:
   conn_type: scheme
   host: host
   extra_dejson:
       extra__google_cloud_platform__keyfile_dict: AAA

Currently, the extra parameter can only be defined as follows.

conn_c:
   conn_type: scheme
   host: host
   extra_dejson: {"extra__google_cloud_platform__keyfile_dict": "file_content"}

It works, but it's not perfect.

AAA being the file name?

@mik-laj
Copy link
Member

mik-laj commented Jun 26, 2020

@VinayGb665 The content of the extra field depends on the implementation of the specific hook.
https://airflow.readthedocs.io/en/latest/howto/connection/gcp.html

For GCP, we have the following keys:

  • extra__google_cloud_platform__project - Project Id
  • extra__google_cloud_platform__key_path - Keyfile Path
  • extra__google_cloud_platform__keyfile_dict - Keyfile JSON
  • extra__google_cloud_platform__scope - Scopes
  • extra__google_cloud_platform__num_retries - Number of Retries

https://airflow.readthedocs.io/en/latest/howto/connection/gcp.html

From a technical point of view, an extra is a JSON object with any keys and any values.

@VinayGb665
Copy link
Contributor Author

@mik-laj If the intended YAML would look something like this then it should work fine with the current implementation itself

extra_dejson:
  extra__google_cloud_platform__keyfile_dict:
    a: b
    c: d
  extra__google_cloud_platform__num_retries: 1

@mik-laj
Copy link
Member

mik-laj commented Jun 26, 2020

Please create new PR :-)

XD-DENG added a commit to XD-DENG/airflow that referenced this pull request Nov 24, 2020
- Support towards YAML is added in PR apache#9477
  Most docs were updated for this. But a few docstrings and exception logging were missed

- Fix a minor error in the doc .rst file.
kaxil pushed a commit that referenced this pull request Nov 25, 2020
- Support towards YAML is added in PR #9477
  Most docs were updated for this. But a few docstrings and exception logging were missed
leahecole pushed a commit to GoogleCloudPlatform/composer-airflow that referenced this pull request Sep 15, 2021
- Support towards YAML is added in PR apache/airflow#9477
  Most docs were updated for this. But a few docstrings and exception logging were missed

GitOrigin-RevId: c6467ba12d4a94027137e3173097d73be56c5d12
leahecole pushed a commit to GoogleCloudPlatform/composer-airflow that referenced this pull request Sep 17, 2021
- Support towards YAML is added in PR apache/airflow#9477
  Most docs were updated for this. But a few docstrings and exception logging were missed

GitOrigin-RevId: c6467ba12d4a94027137e3173097d73be56c5d12
leahecole pushed a commit to GoogleCloudPlatform/composer-airflow that referenced this pull request Sep 23, 2021
- Support towards YAML is added in PR apache/airflow#9477
  Most docs were updated for this. But a few docstrings and exception logging were missed

GitOrigin-RevId: c6467ba12d4a94027137e3173097d73be56c5d12
leahecole pushed a commit to GoogleCloudPlatform/composer-airflow that referenced this pull request Nov 27, 2021
- Support towards YAML is added in PR apache/airflow#9477
  Most docs were updated for this. But a few docstrings and exception logging were missed

GitOrigin-RevId: c6467ba12d4a94027137e3173097d73be56c5d12
leahecole pushed a commit to GoogleCloudPlatform/composer-airflow that referenced this pull request Mar 10, 2022
- Support towards YAML is added in PR apache/airflow#9477
  Most docs were updated for this. But a few docstrings and exception logging were missed

GitOrigin-RevId: c6467ba12d4a94027137e3173097d73be56c5d12
leahecole pushed a commit to GoogleCloudPlatform/composer-airflow that referenced this pull request Jun 4, 2022
- Support towards YAML is added in PR apache/airflow#9477
  Most docs were updated for this. But a few docstrings and exception logging were missed

GitOrigin-RevId: c6467ba12d4a94027137e3173097d73be56c5d12
leahecole pushed a commit to GoogleCloudPlatform/composer-airflow that referenced this pull request Jun 7, 2022
- Support towards YAML is added in PR apache/airflow#9477
  Most docs were updated for this. But a few docstrings and exception logging were missed

GitOrigin-RevId: c6467ba12d4a94027137e3173097d73be56c5d12
kosteev pushed a commit to GoogleCloudPlatform/composer-airflow that referenced this pull request Jul 9, 2022
- Support towards YAML is added in PR apache/airflow#9477
  Most docs were updated for this. But a few docstrings and exception logging were missed

GitOrigin-RevId: c6467ba12d4a94027137e3173097d73be56c5d12
leahecole pushed a commit to GoogleCloudPlatform/composer-airflow that referenced this pull request Aug 27, 2022
- Support towards YAML is added in PR apache/airflow#9477
  Most docs were updated for this. But a few docstrings and exception logging were missed

GitOrigin-RevId: c6467ba12d4a94027137e3173097d73be56c5d12
leahecole pushed a commit to GoogleCloudPlatform/composer-airflow that referenced this pull request Oct 4, 2022
- Support towards YAML is added in PR apache/airflow#9477
  Most docs were updated for this. But a few docstrings and exception logging were missed

GitOrigin-RevId: c6467ba12d4a94027137e3173097d73be56c5d12
aglipska pushed a commit to GoogleCloudPlatform/composer-airflow that referenced this pull request Oct 7, 2022
- Support towards YAML is added in PR apache/airflow#9477
  Most docs were updated for this. But a few docstrings and exception logging were missed

GitOrigin-RevId: c6467ba12d4a94027137e3173097d73be56c5d12
leahecole pushed a commit to GoogleCloudPlatform/composer-airflow that referenced this pull request Dec 7, 2022
- Support towards YAML is added in PR apache/airflow#9477
  Most docs were updated for this. But a few docstrings and exception logging were missed

GitOrigin-RevId: c6467ba12d4a94027137e3173097d73be56c5d12
leahecole pushed a commit to GoogleCloudPlatform/composer-airflow that referenced this pull request Jan 27, 2023
- Support towards YAML is added in PR apache/airflow#9477
  Most docs were updated for this. But a few docstrings and exception logging were missed

GitOrigin-RevId: c6467ba12d4a94027137e3173097d73be56c5d12
kosteev pushed a commit to kosteev/composer-airflow-test-copybara that referenced this pull request Sep 12, 2024
- Support towards YAML is added in PR apache/airflow#9477
  Most docs were updated for this. But a few docstrings and exception logging were missed

GitOrigin-RevId: c6467ba12d4a94027137e3173097d73be56c5d12
kosteev pushed a commit to kosteev/composer-airflow-test-copybara that referenced this pull request Sep 12, 2024
- Support towards YAML is added in PR apache/airflow#9477
  Most docs were updated for this. But a few docstrings and exception logging were missed

GitOrigin-RevId: c6467ba12d4a94027137e3173097d73be56c5d12
kosteev pushed a commit to GoogleCloudPlatform/composer-airflow that referenced this pull request Sep 17, 2024
- Support towards YAML is added in PR apache/airflow#9477
  Most docs were updated for this. But a few docstrings and exception logging were missed

GitOrigin-RevId: c6467ba12d4a94027137e3173097d73be56c5d12
kosteev pushed a commit to GoogleCloudPlatform/composer-airflow that referenced this pull request Nov 7, 2024
- Support towards YAML is added in PR apache/airflow#9477
  Most docs were updated for this. But a few docstrings and exception logging were missed

GitOrigin-RevId: c6467ba12d4a94027137e3173097d73be56c5d12
kosteev pushed a commit to GoogleCloudPlatform/composer-airflow that referenced this pull request May 1, 2025
- Support towards YAML is added in PR apache/airflow#9477
  Most docs were updated for this. But a few docstrings and exception logging were missed

GitOrigin-RevId: c6467ba12d4a94027137e3173097d73be56c5d12
kosteev pushed a commit to GoogleCloudPlatform/composer-airflow that referenced this pull request May 21, 2025
- Support towards YAML is added in PR apache/airflow#9477
  Most docs were updated for this. But a few docstrings and exception logging were missed

GitOrigin-RevId: c6467ba12d4a94027137e3173097d73be56c5d12
kosteev pushed a commit to GoogleCloudPlatform/composer-airflow that referenced this pull request Sep 16, 2025
- Support towards YAML is added in PR apache/airflow#9477
  Most docs were updated for this. But a few docstrings and exception logging were missed

GitOrigin-RevId: c6467ba12d4a94027137e3173097d73be56c5d12
kosteev pushed a commit to GoogleCloudPlatform/composer-airflow that referenced this pull request Oct 15, 2025
- Support towards YAML is added in PR apache/airflow#9477
  Most docs were updated for this. But a few docstrings and exception logging were missed

GitOrigin-RevId: c6467ba12d4a94027137e3173097d73be56c5d12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

YAML file format in LocalFilesystemBackend

2 participants