vincbeck commented on code in PR #66418:
URL: https://github.com/apache/airflow/pull/66418#discussion_r3219552049


##########
airflow-core/src/airflow/cli/commands/team_command.py:
##########
@@ -155,3 +156,33 @@ def team_list(args, session=NEW_SESSION):
         print(NO_TEAMS_LIST_MSG)
     else:
         _show_teams(teams=teams, output=args.output)
+
+
+@cli_utils.action_cli
+@providers_configuration_loaded
+@provide_session
+def team_sync(args, session=NEW_SESSION):
+    """Sync missing teams from the dag bundle config."""
+    existing_teams = {t.name for t in 
session.scalars(select(Team).order_by(Team.name)).all()}

Review Comment:
   You can use `Team.get_all_team_names` instead



##########
airflow-core/src/airflow/cli/commands/team_command.py:
##########
@@ -155,3 +156,33 @@ def team_list(args, session=NEW_SESSION):
         print(NO_TEAMS_LIST_MSG)
     else:
         _show_teams(teams=teams, output=args.output)
+
+
+@cli_utils.action_cli
+@providers_configuration_loaded
+@provide_session
+def team_sync(args, session=NEW_SESSION):
+    """Sync missing teams from the dag bundle config."""
+    existing_teams = {t.name for t in 
session.scalars(select(Team).order_by(Team.name)).all()}
+
+    dag_bundle_teams = {
+        bundle.team_name
+        for bundle in DagBundlesManager()._bundle_config.values()
+        if bundle.team_name is not None
+    }
+
+    teams_added = 0
+
+    try:
+        for team_name in dag_bundle_teams:

Review Comment:
   You can do `dag_bundle_teams - existing_teams` to get the list of teams that 
are defined in the dag bundles but not in the database



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to