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

Add bundle_name and latest_bundle_version to dags list command #45646

Closed
1 task done
jedcunningham opened this issue Jan 14, 2025 · 12 comments · Fixed by #45779
Closed
1 task done

Add bundle_name and latest_bundle_version to dags list command #45646

jedcunningham opened this issue Jan 14, 2025 · 12 comments · Fixed by #45779
Assignees
Labels
AIP-66: DAG Bundle/Manifest area:CLI kind:meta High-level information important to the community

Comments

@jedcunningham
Copy link
Member

Body

We need to add bundle_name and latest_bundle_version to the dags list command

Committer

  • I acknowledge that I am a maintainer/committer of the Apache Airflow project.
@jedcunningham jedcunningham added the kind:meta High-level information important to the community label Jan 14, 2025
@dosubot dosubot bot added the area:CLI label Jan 14, 2025
@ambika-garg
Copy link
Contributor

Hey @jedcunningham, I can take this up. You can assign it to me.

@ambika-garg
Copy link
Contributor

Hey @jedcunningham, I have a quick question about creating DAG Bundles. I noticed several classes under dag_processing/bundles. How can we use them to create bundles locally?

@jedcunningham
Copy link
Member Author

jedcunningham commented Jan 17, 2025

You set them in config. The default and example there should get you going, but feel free to reach back out if you get stuck!

@ambika-garg
Copy link
Contributor

I have created a draft PR (#45779) that adds the bundle name as an argument to the dags list command. Could you please review it to ensure it's on the right track? Once confirmed, I will proceed to add the bundle_version argument as well.

@jedcunningham
Copy link
Member Author

Couple things:

@ambika-garg
Copy link
Contributor

Thankyou @jedcunningham for reviewing it, I'll go with the approach enabling DagBag(read_dags_from_db=True) and using the added columns in the output of cli command.

@ambika-garg
Copy link
Contributor

Hi @jedcunningham,

I have a few questions:

  1. I was able to display the bundle name and version in the output as shown in the image. Let me know if this aligns with your expectations. You can also review the changes in the draft PR.
Image
  1. I tested this on LocalBundle, but since it doesn’t support versions, I wanted to test it on GitBundle. However, I encountered an error. I updated the config.yml with the following changes but ran into issues. Could you guide me on whether any specific configurations are required?

  2. As per your suggestion, I attempted to use Dagbag(read_dags_from_db=True). While exploring this approach, I tried using the collect_dags_from_db function from dagbag file, It was unable to load any file from the db.

Looking forward to your guidance!

@ambika-garg
Copy link
Contributor

Once we are good with list_dags command, we can extend the output functionality to the other CLI commands as well.

@jedcunningham
Copy link
Member Author

1. I was able to display the bundle name and version in the output as shown in the image. Let me know if this aligns with your expectations. You can also review the changes in the [draft PR.](https://github.com/apache/airflow/pull/45779)
Image

Yep, exactly!

2. I tested this on LocalBundle, but since it doesn’t support versions, I wanted to test it on GitBundle. However, I encountered an error. I updated the config.yml with the following changes but ran into issues. Could you guide me on whether any specific configurations are required?

Without the error message, it's tough to say. There has been a bit of churn in GitHook and GitDagBundle recently. If you need a working config, let me know and I'll craft one to share.

3. As per your suggestion, I attempted to use Dagbag(read_dags_from_db=True). While exploring this approach, I tried using the collect_dags_from_db function from [dagbag](https://github.com/apache/airflow/blob/main/airflow/models/dagbag.py) file, It was unable to load any file from the db.

Hmm, in theory, you can just do:

>>> from airflow.models.dagbag import DagBag
>>> bag = DagBag(read_dags_from_db=True)
>>> bag.collect_dags_from_db()
[2025-01-26T19:00:50.726-0700] {dagbag.py:612} INFO - Filling up the DagBag from database
...
>>> bag.dag_ids
['hello', 'mapping_always_short', 'ke_image_override']

Did you get any errors? Or it was just empty?

@ambika-garg
Copy link
Contributor

ambika-garg commented Jan 27, 2025

Hmm, in theory, you can just do:

>>> from airflow.models.dagbag import DagBag
>>> bag = DagBag(read_dags_from_db=True)
>>> bag.collect_dags_from_db()
[2025-01-26T19:00:50.726-0700] {dagbag.py:612} INFO - Filling up the DagBag from database
...
>>> bag.dag_ids
['hello', 'mapping_always_short', 'ke_image_override']

Did you get any errors? Or it was just empty?

Hey @jedcunningham , I get the following error upon trying it.

Image

@ambika-garg
Copy link
Contributor

Could you also please share a working configuration for the GithubDagBundle?

@jedcunningham
Copy link
Member Author

jedcunningham commented Jan 28, 2025

Sounds like your db isn't migrated.

Here is an example. First you need to set up a connection:

AIRFLOW_CONN_AIRFLOW_GIT_CONN='{"host": "https://github.com/apache/airflow.git"}'

Then, add this to your config:

[dag_processor]
dag_bundle_config_list = [
        {
            "name": "airflow_example_dags",
            "classpath": "airflow.dag_processing.bundles.git.GitDagBundle",
            "kwargs": {"tracking_ref": "main", "git_conn_id": "airflow_git_conn", subdir="airflow/example_dags"}
        }
    ]

However, something is broken right now and the processor is getting stuck on servicing the sockets. I'll have to dig into this tomorrow. In the meantime, you can safely go into the db and just put a string in the dag.bundle_version column. That will unblock you for now.

(edit: added .git to the host - we need that!)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AIP-66: DAG Bundle/Manifest area:CLI kind:meta High-level information important to the community
Projects
Development

Successfully merging a pull request may close this issue.

2 participants