prefect-gitlab 0.2.6__tar.gz → 0.3.0__tar.gz
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.
- {prefect_gitlab-0.2.6/prefect_gitlab.egg-info → prefect_gitlab-0.3.0}/PKG-INFO +5 -6
- {prefect_gitlab-0.2.6 → prefect_gitlab-0.3.0}/README.md +1 -1
- {prefect_gitlab-0.2.6 → prefect_gitlab-0.3.0}/prefect_gitlab/_version.py +2 -2
- {prefect_gitlab-0.2.6 → prefect_gitlab-0.3.0}/prefect_gitlab/credentials.py +7 -13
- {prefect_gitlab-0.2.6 → prefect_gitlab-0.3.0}/prefect_gitlab/repositories.py +2 -35
- {prefect_gitlab-0.2.6 → prefect_gitlab-0.3.0/prefect_gitlab.egg-info}/PKG-INFO +5 -6
- {prefect_gitlab-0.2.6 → prefect_gitlab-0.3.0}/prefect_gitlab.egg-info/requires.txt +2 -4
- {prefect_gitlab-0.2.6 → prefect_gitlab-0.3.0}/pyproject.toml +7 -5
- {prefect_gitlab-0.2.6 → prefect_gitlab-0.3.0}/tests/conftest.py +0 -11
- {prefect_gitlab-0.2.6 → prefect_gitlab-0.3.0}/tests/test_repositories.py +4 -35
- {prefect_gitlab-0.2.6 → prefect_gitlab-0.3.0}/LICENSE +0 -0
- {prefect_gitlab-0.2.6 → prefect_gitlab-0.3.0}/MANIFEST.in +0 -0
- {prefect_gitlab-0.2.6 → prefect_gitlab-0.3.0}/prefect_gitlab/__init__.py +0 -0
- {prefect_gitlab-0.2.6 → prefect_gitlab-0.3.0}/prefect_gitlab.egg-info/SOURCES.txt +0 -0
- {prefect_gitlab-0.2.6 → prefect_gitlab-0.3.0}/prefect_gitlab.egg-info/dependency_links.txt +0 -0
- {prefect_gitlab-0.2.6 → prefect_gitlab-0.3.0}/prefect_gitlab.egg-info/entry_points.txt +0 -0
- {prefect_gitlab-0.2.6 → prefect_gitlab-0.3.0}/prefect_gitlab.egg-info/top_level.txt +0 -0
- {prefect_gitlab-0.2.6 → prefect_gitlab-0.3.0}/setup.cfg +0 -0
- {prefect_gitlab-0.2.6 → prefect_gitlab-0.3.0}/tests/test_credentials.py +0 -0
- {prefect_gitlab-0.2.6 → prefect_gitlab-0.3.0}/tests/test_version.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: prefect-gitlab
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.0
|
|
4
4
|
Summary: A Prefect collection for working with GitLab repositories.
|
|
5
5
|
Author-email: "Prefect Technologies, Inc." <help@prefect.io>
|
|
6
6
|
License: Apache License 2.0
|
|
@@ -11,16 +11,15 @@ Classifier: Intended Audience :: Developers
|
|
|
11
11
|
Classifier: Intended Audience :: System Administrators
|
|
12
12
|
Classifier: License :: OSI Approved :: Apache Software License
|
|
13
13
|
Classifier: Programming Language :: Python :: 3 :: Only
|
|
14
|
-
Classifier: Programming Language :: Python :: 3.8
|
|
15
14
|
Classifier: Programming Language :: Python :: 3.9
|
|
16
15
|
Classifier: Programming Language :: Python :: 3.10
|
|
17
16
|
Classifier: Programming Language :: Python :: 3.11
|
|
18
17
|
Classifier: Programming Language :: Python :: 3.12
|
|
19
18
|
Classifier: Topic :: Software Development :: Libraries
|
|
20
|
-
Requires-Python: >=3.
|
|
19
|
+
Requires-Python: >=3.9
|
|
21
20
|
Description-Content-Type: text/markdown
|
|
22
21
|
License-File: LICENSE
|
|
23
|
-
Requires-Dist: prefect
|
|
22
|
+
Requires-Dist: prefect>=3.0.0rc1
|
|
24
23
|
Requires-Dist: python-gitlab>=3.12.0
|
|
25
24
|
Requires-Dist: tenacity>=8.2.3
|
|
26
25
|
Provides-Extra: dev
|
|
@@ -31,12 +30,12 @@ Requires-Dist: mkdocs-gen-files; extra == "dev"
|
|
|
31
30
|
Requires-Dist: mkdocs-material; extra == "dev"
|
|
32
31
|
Requires-Dist: mkdocs; extra == "dev"
|
|
33
32
|
Requires-Dist: mkdocstrings[python]; extra == "dev"
|
|
34
|
-
Requires-Dist: mock; python_version < "3.8" and extra == "dev"
|
|
35
33
|
Requires-Dist: mypy; extra == "dev"
|
|
36
34
|
Requires-Dist: pillow; extra == "dev"
|
|
37
35
|
Requires-Dist: pre-commit; extra == "dev"
|
|
38
36
|
Requires-Dist: pytest-asyncio; extra == "dev"
|
|
39
37
|
Requires-Dist: pytest; extra == "dev"
|
|
38
|
+
Requires-Dist: pytest-env; extra == "dev"
|
|
40
39
|
Requires-Dist: pytest-xdist; extra == "dev"
|
|
41
40
|
|
|
42
41
|
# prefect-gitlab
|
|
@@ -56,7 +55,7 @@ Requires-Dist: pytest-xdist; extra == "dev"
|
|
|
56
55
|
|
|
57
56
|
### Python setup
|
|
58
57
|
|
|
59
|
-
Requires an installation of Python 3.
|
|
58
|
+
Requires an installation of Python 3.9 or higher.
|
|
60
59
|
|
|
61
60
|
We recommend using a Python virtual environment manager such as pipenv, conda, or virtualenv.
|
|
62
61
|
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
"""Module used to enable authenticated interactions with GitLab"""
|
|
2
2
|
|
|
3
|
+
from typing import Optional
|
|
4
|
+
|
|
3
5
|
from gitlab import Gitlab
|
|
4
|
-
from pydantic import
|
|
6
|
+
from pydantic import Field, SecretStr
|
|
5
7
|
|
|
6
8
|
from prefect.blocks.core import Block
|
|
7
9
|
|
|
8
|
-
if PYDANTIC_VERSION.startswith("2."):
|
|
9
|
-
from pydantic.v1 import Field, HttpUrl, SecretStr
|
|
10
|
-
else:
|
|
11
|
-
from pydantic import Field, HttpUrl, SecretStr
|
|
12
|
-
|
|
13
10
|
|
|
14
11
|
class GitLabCredentials(Block):
|
|
15
12
|
"""
|
|
@@ -29,17 +26,14 @@ class GitLabCredentials(Block):
|
|
|
29
26
|
"""
|
|
30
27
|
|
|
31
28
|
_block_type_name = "GitLab Credentials"
|
|
32
|
-
_logo_url =
|
|
33
|
-
url="https://images.ctfassets.net/gm98wzqotmnx/55edIimT4g9gbjhkh5a3Sp/dfdb9391d8f45c2e93e72e3a4d350771/gitlab-logo-500.png?h=250", # noqa
|
|
34
|
-
scheme="https",
|
|
35
|
-
)
|
|
29
|
+
_logo_url = "https://images.ctfassets.net/gm98wzqotmnx/55edIimT4g9gbjhkh5a3Sp/dfdb9391d8f45c2e93e72e3a4d350771/gitlab-logo-500.png?h=250"
|
|
36
30
|
|
|
37
|
-
token: SecretStr = Field(
|
|
38
|
-
|
|
31
|
+
token: Optional[SecretStr] = Field(
|
|
32
|
+
title="Personal Access Token",
|
|
39
33
|
default=None,
|
|
40
34
|
description="A GitLab Personal Access Token with read_repository scope.",
|
|
41
35
|
)
|
|
42
|
-
url: str = Field(
|
|
36
|
+
url: Optional[str] = Field(
|
|
43
37
|
default=None, title="URL", description="URL to self-hosted GitLab instances."
|
|
44
38
|
)
|
|
45
39
|
|
|
@@ -48,19 +48,12 @@ from pathlib import Path
|
|
|
48
48
|
from tempfile import TemporaryDirectory
|
|
49
49
|
from typing import Optional, Tuple, Union
|
|
50
50
|
|
|
51
|
-
from pydantic import
|
|
51
|
+
from pydantic import Field
|
|
52
52
|
from tenacity import retry, stop_after_attempt, wait_fixed, wait_random
|
|
53
53
|
|
|
54
|
-
from prefect.exceptions import InvalidRepositoryURLError
|
|
55
54
|
from prefect.filesystems import ReadableDeploymentStorage
|
|
56
55
|
from prefect.utilities.asyncutils import sync_compatible
|
|
57
56
|
from prefect.utilities.processutils import run_process
|
|
58
|
-
|
|
59
|
-
if PYDANTIC_VERSION.startswith("2."):
|
|
60
|
-
from pydantic.v1 import Field, HttpUrl, validator
|
|
61
|
-
else:
|
|
62
|
-
from pydantic import Field, HttpUrl, validator
|
|
63
|
-
|
|
64
57
|
from prefect_gitlab.credentials import GitLabCredentials
|
|
65
58
|
|
|
66
59
|
# Create get_directory retry settings
|
|
@@ -80,10 +73,7 @@ class GitLabRepository(ReadableDeploymentStorage):
|
|
|
80
73
|
"""
|
|
81
74
|
|
|
82
75
|
_block_type_name = "GitLab Repository"
|
|
83
|
-
_logo_url =
|
|
84
|
-
url="https://images.ctfassets.net/gm98wzqotmnx/55edIimT4g9gbjhkh5a3Sp/dfdb9391d8f45c2e93e72e3a4d350771/gitlab-logo-500.png?h=250", # noqa
|
|
85
|
-
scheme="https",
|
|
86
|
-
)
|
|
76
|
+
_logo_url = "https://images.ctfassets.net/gm98wzqotmnx/55edIimT4g9gbjhkh5a3Sp/dfdb9391d8f45c2e93e72e3a4d350771/gitlab-logo-500.png?h=250"
|
|
87
77
|
_description = "Interact with files stored in GitLab repositories."
|
|
88
78
|
|
|
89
79
|
repository: str = Field(
|
|
@@ -108,29 +98,6 @@ class GitLabRepository(ReadableDeploymentStorage):
|
|
|
108
98
|
"private GitLab repos.",
|
|
109
99
|
)
|
|
110
100
|
|
|
111
|
-
@validator("credentials")
|
|
112
|
-
def _ensure_credentials_go_with_http(cls, v: str, values: dict) -> str:
|
|
113
|
-
"""Ensure that credentials are not provided with 'SSH' formatted GitLub URLs.
|
|
114
|
-
Note: validates `access_token` specifically so that it only fires when
|
|
115
|
-
private repositories are used.
|
|
116
|
-
"""
|
|
117
|
-
if v is not None:
|
|
118
|
-
if urllib.parse.urlparse(values["repository"]).scheme not in [
|
|
119
|
-
"https",
|
|
120
|
-
"http",
|
|
121
|
-
]:
|
|
122
|
-
raise InvalidRepositoryURLError(
|
|
123
|
-
(
|
|
124
|
-
"Credentials can only be used with GitLab repositories "
|
|
125
|
-
"using the 'HTTPS'/'HTTP' format. You must either remove the "
|
|
126
|
-
"credential if you wish to use the 'SSH' format and are not "
|
|
127
|
-
"using a private repository, or you must change the repository "
|
|
128
|
-
"URL to the 'HTTPS'/'HTTP' format."
|
|
129
|
-
)
|
|
130
|
-
)
|
|
131
|
-
|
|
132
|
-
return v
|
|
133
|
-
|
|
134
101
|
def _create_repo_url(self) -> str:
|
|
135
102
|
"""Format the URL provided to the `git clone` command.
|
|
136
103
|
For private repos: https://<oauth-key>@gitlab.com/<username>/<repo>.git
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: prefect-gitlab
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.0
|
|
4
4
|
Summary: A Prefect collection for working with GitLab repositories.
|
|
5
5
|
Author-email: "Prefect Technologies, Inc." <help@prefect.io>
|
|
6
6
|
License: Apache License 2.0
|
|
@@ -11,16 +11,15 @@ Classifier: Intended Audience :: Developers
|
|
|
11
11
|
Classifier: Intended Audience :: System Administrators
|
|
12
12
|
Classifier: License :: OSI Approved :: Apache Software License
|
|
13
13
|
Classifier: Programming Language :: Python :: 3 :: Only
|
|
14
|
-
Classifier: Programming Language :: Python :: 3.8
|
|
15
14
|
Classifier: Programming Language :: Python :: 3.9
|
|
16
15
|
Classifier: Programming Language :: Python :: 3.10
|
|
17
16
|
Classifier: Programming Language :: Python :: 3.11
|
|
18
17
|
Classifier: Programming Language :: Python :: 3.12
|
|
19
18
|
Classifier: Topic :: Software Development :: Libraries
|
|
20
|
-
Requires-Python: >=3.
|
|
19
|
+
Requires-Python: >=3.9
|
|
21
20
|
Description-Content-Type: text/markdown
|
|
22
21
|
License-File: LICENSE
|
|
23
|
-
Requires-Dist: prefect
|
|
22
|
+
Requires-Dist: prefect>=3.0.0rc1
|
|
24
23
|
Requires-Dist: python-gitlab>=3.12.0
|
|
25
24
|
Requires-Dist: tenacity>=8.2.3
|
|
26
25
|
Provides-Extra: dev
|
|
@@ -31,12 +30,12 @@ Requires-Dist: mkdocs-gen-files; extra == "dev"
|
|
|
31
30
|
Requires-Dist: mkdocs-material; extra == "dev"
|
|
32
31
|
Requires-Dist: mkdocs; extra == "dev"
|
|
33
32
|
Requires-Dist: mkdocstrings[python]; extra == "dev"
|
|
34
|
-
Requires-Dist: mock; python_version < "3.8" and extra == "dev"
|
|
35
33
|
Requires-Dist: mypy; extra == "dev"
|
|
36
34
|
Requires-Dist: pillow; extra == "dev"
|
|
37
35
|
Requires-Dist: pre-commit; extra == "dev"
|
|
38
36
|
Requires-Dist: pytest-asyncio; extra == "dev"
|
|
39
37
|
Requires-Dist: pytest; extra == "dev"
|
|
38
|
+
Requires-Dist: pytest-env; extra == "dev"
|
|
40
39
|
Requires-Dist: pytest-xdist; extra == "dev"
|
|
41
40
|
|
|
42
41
|
# prefect-gitlab
|
|
@@ -56,7 +55,7 @@ Requires-Dist: pytest-xdist; extra == "dev"
|
|
|
56
55
|
|
|
57
56
|
### Python setup
|
|
58
57
|
|
|
59
|
-
Requires an installation of Python 3.
|
|
58
|
+
Requires an installation of Python 3.9 or higher.
|
|
60
59
|
|
|
61
60
|
We recommend using a Python virtual environment manager such as pipenv, conda, or virtualenv.
|
|
62
61
|
|
|
@@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta"
|
|
|
6
6
|
name = "prefect-gitlab"
|
|
7
7
|
description = "A Prefect collection for working with GitLab repositories."
|
|
8
8
|
readme = "README.md"
|
|
9
|
-
requires-python = ">=3.
|
|
9
|
+
requires-python = ">=3.9"
|
|
10
10
|
license = { text = "Apache License 2.0" }
|
|
11
11
|
keywords = ["prefect"]
|
|
12
12
|
authors = [{ name = "Prefect Technologies, Inc.", email = "help@prefect.io" }]
|
|
@@ -16,7 +16,6 @@ classifiers = [
|
|
|
16
16
|
"Intended Audience :: System Administrators",
|
|
17
17
|
"License :: OSI Approved :: Apache Software License",
|
|
18
18
|
"Programming Language :: Python :: 3 :: Only",
|
|
19
|
-
"Programming Language :: Python :: 3.8",
|
|
20
19
|
"Programming Language :: Python :: 3.9",
|
|
21
20
|
"Programming Language :: Python :: 3.10",
|
|
22
21
|
"Programming Language :: Python :: 3.11",
|
|
@@ -24,7 +23,7 @@ classifiers = [
|
|
|
24
23
|
"Topic :: Software Development :: Libraries",
|
|
25
24
|
]
|
|
26
25
|
dependencies = [
|
|
27
|
-
"prefect>=
|
|
26
|
+
"prefect>=3.0.0rc1",
|
|
28
27
|
"python-gitlab>=3.12.0",
|
|
29
28
|
"tenacity>=8.2.3",
|
|
30
29
|
]
|
|
@@ -39,12 +38,12 @@ dev = [
|
|
|
39
38
|
"mkdocs-material",
|
|
40
39
|
"mkdocs",
|
|
41
40
|
"mkdocstrings[python]",
|
|
42
|
-
"mock; python_version < '3.8'",
|
|
43
41
|
"mypy",
|
|
44
42
|
"pillow",
|
|
45
43
|
"pre-commit",
|
|
46
44
|
"pytest-asyncio",
|
|
47
45
|
"pytest",
|
|
46
|
+
"pytest-env",
|
|
48
47
|
"pytest-xdist",
|
|
49
48
|
]
|
|
50
49
|
|
|
@@ -57,7 +56,7 @@ prefect_gitlab = "prefect_gitlab"
|
|
|
57
56
|
[tool.setuptools_scm]
|
|
58
57
|
version_file = "prefect_gitlab/_version.py"
|
|
59
58
|
root = "../../.."
|
|
60
|
-
tag_regex = "^prefect-gitlab-(?P<version>\\d+\\.\\d+\\.\\d+)$"
|
|
59
|
+
tag_regex = "^prefect-gitlab-(?P<version>\\d+\\.\\d+\\.\\d+(?:[a-zA-Z0-9]+(?:\\.[a-zA-Z0-9]+)*)?)$"
|
|
61
60
|
fallback_version = "0.0.0"
|
|
62
61
|
git_describe_command = 'git describe --dirty --tags --long --match "prefect-gitlab-*[0-9]*"'
|
|
63
62
|
|
|
@@ -77,3 +76,6 @@ show_missing = true
|
|
|
77
76
|
|
|
78
77
|
[tool.pytest.ini_options]
|
|
79
78
|
asyncio_mode = "auto"
|
|
79
|
+
env = [
|
|
80
|
+
"PREFECT_TEST_MODE=1",
|
|
81
|
+
]
|
|
@@ -10,14 +10,3 @@ def prefect_db():
|
|
|
10
10
|
"""
|
|
11
11
|
with prefect_test_harness():
|
|
12
12
|
yield
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
@pytest.fixture(autouse=True)
|
|
16
|
-
def reset_object_registry():
|
|
17
|
-
"""
|
|
18
|
-
Ensures each test has a clean object registry.
|
|
19
|
-
"""
|
|
20
|
-
from prefect.context import PrefectObjectRegistry
|
|
21
|
-
|
|
22
|
-
with PrefectObjectRegistry():
|
|
23
|
-
yield
|
|
@@ -3,20 +3,13 @@ from pathlib import Path
|
|
|
3
3
|
from tempfile import TemporaryDirectory
|
|
4
4
|
from typing import Set, Tuple
|
|
5
5
|
|
|
6
|
-
import pytest
|
|
7
|
-
from pydantic import VERSION as PYDANTIC_VERSION
|
|
8
|
-
|
|
9
|
-
from prefect.exceptions import InvalidRepositoryURLError
|
|
10
|
-
from prefect.testing.utilities import AsyncMock
|
|
11
|
-
|
|
12
|
-
if PYDANTIC_VERSION.startswith("2."):
|
|
13
|
-
from pydantic.v1 import SecretStr
|
|
14
|
-
else:
|
|
15
|
-
from pydantic import SecretStr
|
|
16
|
-
|
|
17
6
|
import prefect_gitlab
|
|
7
|
+
import pytest
|
|
18
8
|
from prefect_gitlab.credentials import GitLabCredentials
|
|
19
9
|
from prefect_gitlab.repositories import GitLabRepository # noqa: E402
|
|
10
|
+
from pydantic import SecretStr
|
|
11
|
+
|
|
12
|
+
from prefect.testing.utilities import AsyncMock
|
|
20
13
|
|
|
21
14
|
|
|
22
15
|
class TestGitLab:
|
|
@@ -170,30 +163,6 @@ class TestGitLab:
|
|
|
170
163
|
]
|
|
171
164
|
assert mock.await_args[0][0][: len(expected_cmd)] == expected_cmd
|
|
172
165
|
|
|
173
|
-
async def test_ssh_fails_with_credential(self, monkeypatch):
|
|
174
|
-
"""Ensure that credentials cannot be passed in if the URL is not in the HTTPS/HTTP
|
|
175
|
-
format.
|
|
176
|
-
"""
|
|
177
|
-
|
|
178
|
-
class p:
|
|
179
|
-
returncode = 0
|
|
180
|
-
|
|
181
|
-
mock = AsyncMock(return_value=p())
|
|
182
|
-
monkeypatch.setattr(prefect_gitlab.repositories, "run_process", mock)
|
|
183
|
-
credential = "XYZ"
|
|
184
|
-
error_msg = (
|
|
185
|
-
"Credentials can only be used with GitLab repositories "
|
|
186
|
-
"using the 'HTTPS'/'HTTP' format. You must either remove the "
|
|
187
|
-
"credential if you wish to use the 'SSH' format and are not "
|
|
188
|
-
"using a private repository, or you must change the repository "
|
|
189
|
-
"URL to the 'HTTPS'/'HTTP' format."
|
|
190
|
-
)
|
|
191
|
-
with pytest.raises(InvalidRepositoryURLError, match=error_msg):
|
|
192
|
-
GitLabRepository(
|
|
193
|
-
repository="git@gitlab.com:PrefectHQ/prefect.git",
|
|
194
|
-
credentials=GitLabCredentials(token=SecretStr(credential)),
|
|
195
|
-
)
|
|
196
|
-
|
|
197
166
|
async def test_dir_contents_copied_correctly_with_get_directory(self, monkeypatch): # noqa
|
|
198
167
|
"""Check that `get_directory` is able to correctly copy contents from src->dst""" # noqa
|
|
199
168
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|