apache-airflow-providers-git 0.0.8rc1__py3-none-any.whl → 0.0.9rc1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -29,7 +29,7 @@ from airflow import __version__ as airflow_version
29
29
 
30
30
  __all__ = ["__version__"]
31
31
 
32
- __version__ = "0.0.8"
32
+ __version__ = "0.0.9"
33
33
 
34
34
  if packaging.version.parse(packaging.version.parse(airflow_version).base_version) < packaging.version.parse(
35
35
  "3.0.0"
@@ -17,13 +17,15 @@
17
17
  from __future__ import annotations
18
18
 
19
19
  import os
20
+ import shutil
20
21
  from contextlib import nullcontext
21
22
  from pathlib import Path
22
23
  from urllib.parse import urlparse
23
24
 
24
25
  import structlog
25
26
  from git import Repo
26
- from git.exc import BadName, GitCommandError, NoSuchPathError
27
+ from git.exc import BadName, GitCommandError, InvalidGitRepositoryError, NoSuchPathError
28
+ from tenacity import retry, retry_if_exception_type, stop_after_attempt
27
29
 
28
30
  from airflow.dag_processing.bundles.base import BaseDagBundle
29
31
  from airflow.exceptions import AirflowException
@@ -91,11 +93,21 @@ class GitDagBundle(BaseDagBundle):
91
93
  with self.lock():
92
94
  cm = self.hook.configure_hook_env() if self.hook else nullcontext()
93
95
  with cm:
94
- self._clone_bare_repo_if_required()
96
+ try:
97
+ self._clone_bare_repo_if_required()
98
+ except GitCommandError as e:
99
+ raise RuntimeError("Error cloning repository") from e
100
+ except InvalidGitRepositoryError as e:
101
+ raise RuntimeError(f"Invalid git repository at {self.bare_repo_path}") from e
95
102
  self._ensure_version_in_bare_repo()
96
103
  self.bare_repo.close()
97
104
 
98
- self._clone_repo_if_required()
105
+ try:
106
+ self._clone_repo_if_required()
107
+ except GitCommandError as e:
108
+ raise RuntimeError("Error cloning repository") from e
109
+ except InvalidGitRepositoryError as e:
110
+ raise RuntimeError(f"Invalid git repository at {self.repo_path}") from e
99
111
  self.repo.git.checkout(self.tracking_ref)
100
112
  self._log.debug("bundle initialize", version=self.version)
101
113
  if self.version:
@@ -113,36 +125,65 @@ class GitDagBundle(BaseDagBundle):
113
125
  self._initialize()
114
126
  super().initialize()
115
127
 
128
+ @retry(
129
+ retry=retry_if_exception_type((InvalidGitRepositoryError, GitCommandError)),
130
+ stop=stop_after_attempt(2),
131
+ reraise=True,
132
+ )
116
133
  def _clone_repo_if_required(self) -> None:
117
- if not os.path.exists(self.repo_path):
118
- self._log.info("Cloning repository", repo_path=self.repo_path, bare_repo_path=self.bare_repo_path)
119
- try:
134
+ try:
135
+ if not os.path.exists(self.repo_path):
136
+ self._log.info(
137
+ "Cloning repository", repo_path=self.repo_path, bare_repo_path=self.bare_repo_path
138
+ )
120
139
  Repo.clone_from(
121
140
  url=self.bare_repo_path,
122
141
  to_path=self.repo_path,
123
142
  )
124
- except NoSuchPathError as e:
125
- # Protection should the bare repo be removed manually
126
- raise AirflowException("Repository path: %s not found", self.bare_repo_path) from e
127
- else:
128
- self._log.debug("repo exists", repo_path=self.repo_path)
129
- self.repo = Repo(self.repo_path)
130
-
143
+ else:
144
+ self._log.debug("repo exists", repo_path=self.repo_path)
145
+ self.repo = Repo(self.repo_path)
146
+ except NoSuchPathError as e:
147
+ # Protection should the bare repo be removed manually
148
+ raise AirflowException("Repository path: %s not found", self.bare_repo_path) from e
149
+ except (InvalidGitRepositoryError, GitCommandError) as e:
150
+ self._log.warning(
151
+ "Repository clone/open failed, cleaning up and retrying",
152
+ repo_path=self.repo_path,
153
+ exc=e,
154
+ )
155
+ if os.path.exists(self.repo_path):
156
+ shutil.rmtree(self.repo_path)
157
+ raise
158
+
159
+ @retry(
160
+ retry=retry_if_exception_type((InvalidGitRepositoryError, GitCommandError)),
161
+ stop=stop_after_attempt(2),
162
+ reraise=True,
163
+ )
131
164
  def _clone_bare_repo_if_required(self) -> None:
132
165
  if not self.repo_url:
133
166
  raise AirflowException(f"Connection {self.git_conn_id} doesn't have a host url")
134
- if not os.path.exists(self.bare_repo_path):
135
- self._log.info("Cloning bare repository", bare_repo_path=self.bare_repo_path)
136
- try:
167
+
168
+ try:
169
+ if not os.path.exists(self.bare_repo_path):
170
+ self._log.info("Cloning bare repository", bare_repo_path=self.bare_repo_path)
137
171
  Repo.clone_from(
138
172
  url=self.repo_url,
139
173
  to_path=self.bare_repo_path,
140
174
  bare=True,
141
175
  env=self.hook.env if self.hook else None,
142
176
  )
143
- except GitCommandError as e:
144
- raise AirflowException("Error cloning repository") from e
145
- self.bare_repo = Repo(self.bare_repo_path)
177
+ self.bare_repo = Repo(self.bare_repo_path)
178
+ except (InvalidGitRepositoryError, GitCommandError) as e:
179
+ self._log.warning(
180
+ "Bare repository clone/open failed, cleaning up and retrying",
181
+ bare_repo_path=self.bare_repo_path,
182
+ exc=e,
183
+ )
184
+ if os.path.exists(self.bare_repo_path):
185
+ shutil.rmtree(self.bare_repo_path)
186
+ raise
146
187
 
147
188
  def _ensure_version_in_bare_repo(self) -> None:
148
189
  if not self.version:
@@ -25,7 +25,7 @@ import tempfile
25
25
  from typing import Any
26
26
 
27
27
  from airflow.exceptions import AirflowException
28
- from airflow.providers.git.version_compat import BaseHook
28
+ from airflow.providers.common.compat.sdk import BaseHook
29
29
 
30
30
  log = logging.getLogger(__name__)
31
31
 
@@ -35,9 +35,4 @@ def get_base_airflow_version_tuple() -> tuple[int, int, int]:
35
35
  AIRFLOW_V_3_0_PLUS = get_base_airflow_version_tuple() >= (3, 0, 0)
36
36
  AIRFLOW_V_3_1_PLUS: bool = get_base_airflow_version_tuple() >= (3, 1, 0)
37
37
 
38
- if AIRFLOW_V_3_1_PLUS:
39
- from airflow.sdk import BaseHook
40
- else:
41
- from airflow.hooks.base import BaseHook # type: ignore[attr-defined,no-redef]
42
-
43
- __all__ = ["AIRFLOW_V_3_0_PLUS", "AIRFLOW_V_3_1_PLUS", "BaseHook"]
38
+ __all__ = ["AIRFLOW_V_3_0_PLUS", "AIRFLOW_V_3_1_PLUS"]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: apache-airflow-providers-git
3
- Version: 0.0.8rc1
3
+ Version: 0.0.9rc1
4
4
  Summary: Provider package apache-airflow-providers-git for Apache Airflow
5
5
  Keywords: airflow-provider,git,airflow,integration
6
6
  Author-email: Apache Software Foundation <dev@airflow.apache.org>
@@ -21,10 +21,11 @@ Classifier: Programming Language :: Python :: 3.12
21
21
  Classifier: Programming Language :: Python :: 3.13
22
22
  Classifier: Topic :: System :: Monitoring
23
23
  Requires-Dist: apache-airflow>=3.0.0rc1
24
+ Requires-Dist: apache-airflow-providers-common-compat>=1.8.0rc1
24
25
  Requires-Dist: GitPython>=3.1.44
25
26
  Project-URL: Bug Tracker, https://github.com/apache/airflow/issues
26
- Project-URL: Changelog, https://airflow.staged.apache.org/docs/apache-airflow-providers-git/0.0.8/changelog.html
27
- Project-URL: Documentation, https://airflow.staged.apache.org/docs/apache-airflow-providers-git/0.0.8
27
+ Project-URL: Changelog, https://airflow.staged.apache.org/docs/apache-airflow-providers-git/0.0.9/changelog.html
28
+ Project-URL: Documentation, https://airflow.staged.apache.org/docs/apache-airflow-providers-git/0.0.9
28
29
  Project-URL: Mastodon, https://fosstodon.org/@airflow
29
30
  Project-URL: Slack Chat, https://s.apache.org/airflow-slack
30
31
  Project-URL: Source Code, https://github.com/apache/airflow
@@ -55,7 +56,7 @@ Project-URL: YouTube, https://www.youtube.com/channel/UCSXwxpWZQ7XZ1WL3wqevChA/
55
56
 
56
57
  Package ``apache-airflow-providers-git``
57
58
 
58
- Release: ``0.0.8``
59
+ Release: ``0.0.9``
59
60
 
60
61
 
61
62
  `Distributed version control system (GIT) <https://git-scm.com/>`__
@@ -68,7 +69,7 @@ This is a provider package for ``git`` provider. All classes for this provider p
68
69
  are in ``airflow.providers.git`` python package.
69
70
 
70
71
  You can find package information and changelog for the provider
71
- in the `documentation <https://airflow.apache.org/docs/apache-airflow-providers-git/0.0.8/>`_.
72
+ in the `documentation <https://airflow.apache.org/docs/apache-airflow-providers-git/0.0.9/>`_.
72
73
 
73
74
  Installation
74
75
  ------------
@@ -82,13 +83,33 @@ The package supports the following python versions: 3.10,3.11,3.12,3.13
82
83
  Requirements
83
84
  ------------
84
85
 
85
- ================== ==================
86
- PIP package Version required
87
- ================== ==================
88
- ``apache-airflow`` ``>=3.0.0``
89
- ``GitPython`` ``>=3.1.44``
90
- ================== ==================
86
+ ========================================== ==================
87
+ PIP package Version required
88
+ ========================================== ==================
89
+ ``apache-airflow`` ``>=3.0.0``
90
+ ``apache-airflow-providers-common-compat`` ``>=1.8.0``
91
+ ``GitPython`` ``>=3.1.44``
92
+ ========================================== ==================
93
+
94
+ Cross provider package dependencies
95
+ -----------------------------------
96
+
97
+ Those are dependencies that might be needed in order to use all the features of the package.
98
+ You need to install the specified providers in order to use them.
99
+
100
+ You can install such cross-provider dependencies when installing from PyPI. For example:
101
+
102
+ .. code-block:: bash
103
+
104
+ pip install apache-airflow-providers-git[common.compat]
105
+
106
+
107
+ ================================================================================================================== =================
108
+ Dependent package Extra
109
+ ================================================================================================================== =================
110
+ `apache-airflow-providers-common-compat <https://airflow.apache.org/docs/apache-airflow-providers-common-compat>`_ ``common.compat``
111
+ ================================================================================================================== =================
91
112
 
92
113
  The changelog for the provider package can be found in the
93
- `changelog <https://airflow.apache.org/docs/apache-airflow-providers-git/0.0.8/changelog.html>`_.
114
+ `changelog <https://airflow.apache.org/docs/apache-airflow-providers-git/0.0.9/changelog.html>`_.
94
115
 
@@ -0,0 +1,12 @@
1
+ airflow/providers/git/LICENSE,sha256=gXPVwptPlW1TJ4HSuG5OMPg-a3h43OGMkZRR1rpwfJA,10850
2
+ airflow/providers/git/__init__.py,sha256=1dwM-4yAxdIshbRngFq3J3tU-CkjzDqfjL4e4OsMy68,1490
3
+ airflow/providers/git/get_provider_info.py,sha256=6xC_Jru3CMrhO7r5aX03J4HR6Jl62rp9BWVcLKFjxQQ,1809
4
+ airflow/providers/git/version_compat.py,sha256=cmeoGMcTp0kiFa3GKZlQh31_kMk7UX9nOX8sYyGtuFg,1665
5
+ airflow/providers/git/bundles/__init__.py,sha256=9hdXHABrVpkbpjZgUft39kOFL2xSGeG4GEua0Hmelus,785
6
+ airflow/providers/git/bundles/git.py,sha256=GbdgiHCu74sYnXN-qnloOkoVupiwYWfMPVshIymYyKs,12252
7
+ airflow/providers/git/hooks/__init__.py,sha256=9hdXHABrVpkbpjZgUft39kOFL2xSGeG4GEua0Hmelus,785
8
+ airflow/providers/git/hooks/git.py,sha256=RNEdKVqwjHOQsA6jjXMPkogJJf9lJASj5hXTdK4idgo,4015
9
+ apache_airflow_providers_git-0.0.9rc1.dist-info/entry_points.txt,sha256=k9QR9MAaAm9yDsRDBIK3QOt5Fos3fBCqCngNFPaJnKs,99
10
+ apache_airflow_providers_git-0.0.9rc1.dist-info/WHEEL,sha256=G2gURzTEtmeR8nrdXUJfNiB3VYVxigPQ-bEQujpNiNs,82
11
+ apache_airflow_providers_git-0.0.9rc1.dist-info/METADATA,sha256=3fTz7wuoeSbPpiuRHB-HXLt7CnMdpTwl1bcDNcLUTRo,5190
12
+ apache_airflow_providers_git-0.0.9rc1.dist-info/RECORD,,
@@ -1,12 +0,0 @@
1
- airflow/providers/git/LICENSE,sha256=gXPVwptPlW1TJ4HSuG5OMPg-a3h43OGMkZRR1rpwfJA,10850
2
- airflow/providers/git/__init__.py,sha256=f7FvYWLzw8Jz2nT68590fHdPjL-74IFIlU0hvg_HiQE,1490
3
- airflow/providers/git/get_provider_info.py,sha256=6xC_Jru3CMrhO7r5aX03J4HR6Jl62rp9BWVcLKFjxQQ,1809
4
- airflow/providers/git/version_compat.py,sha256=wu5478Lfl32vjsmb_tx5zQBL2aVynAVK26XqF-5Wou0,1827
5
- airflow/providers/git/bundles/__init__.py,sha256=9hdXHABrVpkbpjZgUft39kOFL2xSGeG4GEua0Hmelus,785
6
- airflow/providers/git/bundles/git.py,sha256=xnaKQu78WiJH4Mp7g3A6aMxpnLKWMCzHt-5CESH0Pnw,10565
7
- airflow/providers/git/hooks/__init__.py,sha256=9hdXHABrVpkbpjZgUft39kOFL2xSGeG4GEua0Hmelus,785
8
- airflow/providers/git/hooks/git.py,sha256=UxH-hPlmX1VphZey1svhJYUhgK1zEWsryh363k_s008,4016
9
- apache_airflow_providers_git-0.0.8rc1.dist-info/entry_points.txt,sha256=k9QR9MAaAm9yDsRDBIK3QOt5Fos3fBCqCngNFPaJnKs,99
10
- apache_airflow_providers_git-0.0.8rc1.dist-info/WHEEL,sha256=G2gURzTEtmeR8nrdXUJfNiB3VYVxigPQ-bEQujpNiNs,82
11
- apache_airflow_providers_git-0.0.8rc1.dist-info/METADATA,sha256=U1az7iWOJyuusrNiEbM_ywwLIEO00gelNX7ZJZiNd88,3860
12
- apache_airflow_providers_git-0.0.8rc1.dist-info/RECORD,,