dbt-platform-helper 10.11.2__py3-none-any.whl → 10.11.3__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.
@@ -1002,8 +1002,8 @@ platform-helper database copy <source_db> <target_db>
1002
1002
 
1003
1003
  [↩ Parent](#platform-helper)
1004
1004
 
1005
- Contains subcommands for getting version information about the current
1006
- project.
1005
+ Contains subcommands for getting version information about the
1006
+ current project.
1007
1007
 
1008
1008
  ## Usage
1009
1009
 
@@ -2,37 +2,37 @@ import click
2
2
 
3
3
  from dbt_platform_helper.utils.click import ClickDocOptGroup
4
4
  from dbt_platform_helper.utils.platform_config import get_environment_pipeline_names
5
- from dbt_platform_helper.utils.versioning import (
6
- check_platform_helper_version_needs_update,
7
- )
8
5
  from dbt_platform_helper.utils.versioning import get_required_platform_helper_version
9
6
 
10
7
 
11
- @click.group(chain=True, cls=ClickDocOptGroup)
12
- def version():
13
- """Contains subcommands for getting version information about the current
14
- project."""
15
- check_platform_helper_version_needs_update()
8
+ class VersionCommand:
9
+ def __init__(self):
10
+ self.command_group = self.version
11
+ self.command = self.get_platform_helper_for_project
16
12
 
13
+ @click.group(chain=True, cls=ClickDocOptGroup)
14
+ def version():
15
+ """Contains subcommands for getting version information about the
16
+ current project."""
17
17
 
18
- @version.command(help="Print the version of platform-tools required by the current project")
19
- @click.option(
20
- "--pipeline",
21
- required=False,
22
- type=click.Choice(get_environment_pipeline_names()),
23
- help="Take into account platform-tools version overrides in the specified pipeline",
24
- )
25
- def get_platform_helper_for_project(pipeline):
26
- """
27
- Version precedence is in this order:
28
- - if the --pipeline option is supplied, the version in 'platform-config.yml' in:
29
- environment_pipelines:
30
- <pipeline>:
31
- ...
32
- versions:
33
- platform-helper
34
- - The version from default_versions/platform-helper in 'platform-config.yml'
35
- - Fall back on the version in the deprecated '.platform-helper-version' file
36
- """
37
- required_version = get_required_platform_helper_version(pipeline)
38
- click.secho(required_version)
18
+ @version.command(help="Print the version of platform-tools required by the current project")
19
+ @click.option(
20
+ "--pipeline",
21
+ required=False,
22
+ type=click.Choice(get_environment_pipeline_names()),
23
+ help="Take into account platform-tools version overrides in the specified pipeline",
24
+ )
25
+ def get_platform_helper_for_project(pipeline):
26
+ """
27
+ Version precedence is in this order:
28
+ - if the --pipeline option is supplied, the version in 'platform-config.yml' in:
29
+ environment_pipelines:
30
+ <pipeline>:
31
+ ...
32
+ versions:
33
+ platform-helper
34
+ - The version from default_versions/platform-helper in 'platform-config.yml'
35
+ - Fall back on the version in the deprecated '.platform-helper-version' file
36
+ """
37
+ required_version = get_required_platform_helper_version(pipeline)
38
+ click.secho(required_version)
@@ -1,17 +1,30 @@
1
- from pathlib import Path
2
-
3
1
  import yaml
4
2
 
3
+ from pathlib import Path
4
+
5
5
  from dbt_platform_helper.constants import PLATFORM_CONFIG_FILE
6
- from dbt_platform_helper.utils.validation import load_and_validate_platform_config
7
6
 
8
7
 
9
- def get_environment_pipeline_names():
10
- if not Path(PLATFORM_CONFIG_FILE).exists():
8
+ def _read_config_file_contents():
9
+ if Path(PLATFORM_CONFIG_FILE).exists():
10
+ return Path(PLATFORM_CONFIG_FILE).read_text()
11
+
12
+
13
+ def load_unvalidated_config_file():
14
+ file_contents = _read_config_file_contents()
15
+ if not file_contents:
16
+ return {}
17
+ try:
18
+ return yaml.safe_load(file_contents)
19
+ except yaml.parser.ParserError:
11
20
  return {}
12
21
 
13
- config = load_and_validate_platform_config(disable_aws_validation=True, disable_file_check=True)
14
- return config.get("environment_pipelines", {}).keys()
22
+
23
+ def get_environment_pipeline_names():
24
+ pipelines_config = load_unvalidated_config_file().get("environment_pipelines")
25
+ if pipelines_config:
26
+ return pipelines_config.keys()
27
+ return {}
15
28
 
16
29
 
17
30
  def is_terraform_project() -> bool:
@@ -615,6 +615,8 @@ def load_and_validate_platform_config(
615
615
  return conf
616
616
  except ParserError:
617
617
  abort_with_error(f"{PLATFORM_CONFIG_FILE} is not valid YAML")
618
+ except SchemaError as e:
619
+ abort_with_error(f"Schema error in {PLATFORM_CONFIG_FILE}. {e}")
618
620
 
619
621
 
620
622
  def config_file_check(path=PLATFORM_CONFIG_FILE):
@@ -16,7 +16,7 @@ from dbt_platform_helper.constants import PLATFORM_HELPER_VERSION_FILE
16
16
  from dbt_platform_helper.exceptions import IncompatibleMajorVersion
17
17
  from dbt_platform_helper.exceptions import IncompatibleMinorVersion
18
18
  from dbt_platform_helper.exceptions import ValidationException
19
- from dbt_platform_helper.utils.validation import load_and_validate_platform_config
19
+ from dbt_platform_helper.utils.platform_config import load_unvalidated_config_file
20
20
 
21
21
  VersionTuple = Optional[Tuple[int, int, int]]
22
22
 
@@ -104,22 +104,40 @@ def get_github_released_version(repository: str, tags: bool = False) -> Tuple[in
104
104
  return parse_version(package_info["tag_name"])
105
105
 
106
106
 
107
+ def _get_latest_release():
108
+ package_info = requests.get("https://pypi.org/pypi/dbt-platform-helper/json").json()
109
+ released_versions = package_info["releases"].keys()
110
+ parsed_released_versions = [parse_version(v) for v in released_versions]
111
+ parsed_released_versions.sort(reverse=True)
112
+ return parsed_released_versions[0]
113
+
114
+
107
115
  def get_platform_helper_versions(include_project_versions=True) -> PlatformHelperVersions:
108
116
  try:
109
117
  locally_installed_version = parse_version(version("dbt-platform-helper"))
110
118
  except PackageNotFoundError:
111
119
  locally_installed_version = None
112
120
 
113
- package_info = requests.get("https://pypi.org/pypi/dbt-platform-helper/json").json()
114
- released_versions = package_info["releases"].keys()
115
- parsed_released_versions = [parse_version(v) for v in released_versions]
116
- parsed_released_versions.sort(reverse=True)
117
- latest_release = parsed_released_versions[0]
121
+ latest_release = _get_latest_release()
122
+
123
+ if not include_project_versions:
124
+ return PlatformHelperVersions(
125
+ local_version=locally_installed_version,
126
+ latest_release=latest_release,
127
+ )
128
+
129
+ deprecated_version_file = Path(PLATFORM_HELPER_VERSION_FILE)
130
+ version_from_file = (
131
+ parse_version(deprecated_version_file.read_text())
132
+ if deprecated_version_file.exists()
133
+ else None
134
+ )
135
+
136
+ platform_config_default, pipeline_overrides = None, {}
118
137
 
119
- platform_config_default, pipeline_overrides, version_from_file = None, {}, None
138
+ platform_config = load_unvalidated_config_file()
120
139
 
121
- if include_project_versions:
122
- platform_config = load_and_validate_platform_config(disable_aws_validation=True)
140
+ if platform_config:
123
141
  platform_config_default = parse_version(
124
142
  platform_config.get("default_versions", {}).get("platform-helper")
125
143
  )
@@ -130,13 +148,6 @@ def get_platform_helper_versions(include_project_versions=True) -> PlatformHelpe
130
148
  if pipeline.get("versions", {}).get("platform-helper")
131
149
  }
132
150
 
133
- deprecated_version_file = Path(PLATFORM_HELPER_VERSION_FILE)
134
- version_from_file = (
135
- parse_version(deprecated_version_file.read_text())
136
- if deprecated_version_file.exists()
137
- else None
138
- )
139
-
140
151
  out = PlatformHelperVersions(
141
152
  local_version=locally_installed_version,
142
153
  latest_release=latest_release,
@@ -145,8 +156,7 @@ def get_platform_helper_versions(include_project_versions=True) -> PlatformHelpe
145
156
  pipeline_overrides=pipeline_overrides,
146
157
  )
147
158
 
148
- if include_project_versions:
149
- _process_version_file_warnings(out)
159
+ _process_version_file_warnings(out)
150
160
 
151
161
  return out
152
162
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: dbt-platform-helper
3
- Version: 10.11.2
3
+ Version: 10.11.3
4
4
  Summary: Set of tools to help transfer applications/services from GOV.UK PaaS to DBT PaaS augmenting AWS Copilot.
5
5
  License: MIT
6
6
  Author: Department for Business and Trade Platform Team
@@ -1,4 +1,4 @@
1
- dbt_platform_helper/COMMANDS.md,sha256=ACnl9RDJ2KjXDU1xu29x5xlqhdFylvdRBxI7InvMu2U,22997
1
+ dbt_platform_helper/COMMANDS.md,sha256=BZdxv8hNF9PZ2fRNozyGkeddbsuVPF2TTlpE1Y4Z2vk,23001
2
2
  dbt_platform_helper/README.md,sha256=B0qN2_u_ASqqgkGDWY2iwNGZt_9tUgMb9XqtaTuzYjw,1530
3
3
  dbt_platform_helper/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  dbt_platform_helper/addon-plans.yml,sha256=O46a_ODsGG9KXmQY_1XbSGqrpSaHSLDe-SdROzHx8Go,4545
@@ -17,7 +17,7 @@ dbt_platform_helper/commands/generate.py,sha256=YLCPb-xcPapGcsLn-7d1Am7BpGp5l0ie
17
17
  dbt_platform_helper/commands/notify.py,sha256=kVJ0s78QMiaEWPVKu_bbMko4DW2uJy2fu8-HNJsglyk,3748
18
18
  dbt_platform_helper/commands/pipeline.py,sha256=jQGwCRpJ_hXK988XmLHzRBHDWmhFzZb37wa75KuSd0M,5945
19
19
  dbt_platform_helper/commands/secrets.py,sha256=2NtV5FGx-ErkMg2QMiDvFOp03cKVbLzgmY8Y504EKJw,3860
20
- dbt_platform_helper/commands/version.py,sha256=2r6c3-PSMMY_VAU32UNaPJJXOsouX1MQDWXnx3ZpGJI,1474
20
+ dbt_platform_helper/commands/version.py,sha256=RcgOu04MzO5qohs8HLqFcGgwfel56rl_MV8cVNqaQYk,1572
21
21
  dbt_platform_helper/constants.py,sha256=fzN2VZt81mspNfdYpNef5_eEjDVsh8GUYmhBMTIfPvI,232
22
22
  dbt_platform_helper/custom_resources/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
23
23
  dbt_platform_helper/custom_resources/s3_object.py,sha256=0mhLuKD0-vwuN1qmnLCrLo2qL58FvtCjNNjH34kac6Y,2526
@@ -91,13 +91,13 @@ dbt_platform_helper/utils/files.py,sha256=wKDPLZSC3tIZrto-0xGYPmemN8Fsn4spdUsNtY
91
91
  dbt_platform_helper/utils/git.py,sha256=9jyLhv37KKE6r-_hb3zvjhTbluA81kdrOdNeG6MB-_M,384
92
92
  dbt_platform_helper/utils/manifests.py,sha256=ji3UYHCxq9tTpkm4MlRa2y0-JOYYqq1pWZ2h_zpj0UU,507
93
93
  dbt_platform_helper/utils/messages.py,sha256=aLx6s9utt__IqlDdeIYq4n82ERwludu2Zfqy0Q2t-x8,115
94
- dbt_platform_helper/utils/platform_config.py,sha256=dEGB6peHB1ywYSdS71JGxbWIuTFRaeQfWelksX9v6bQ,608
94
+ dbt_platform_helper/utils/platform_config.py,sha256=zJYCIsgUk5kNerocTzD7Q2XIrkYhiCu65sx8KQ-d-o8,833
95
95
  dbt_platform_helper/utils/template.py,sha256=raRx4QUCVJtKfvJK08Egg6gwWcs3r3V4nPWcJW4xNhA,574
96
- dbt_platform_helper/utils/validation.py,sha256=2XMizmCGk4oTVU67q72cdc8eyOzL0wxhe7DframhQ8Q,23699
97
- dbt_platform_helper/utils/versioning.py,sha256=h3veQpFoiOjYY9dRVppcBDzVfgZerT0lXuE9QCTo5-c,10710
98
- platform_helper.py,sha256=zjsZKcbyrEQbKfERi0JG8JEL-MgG6EjxIMiWT66kCVg,2299
99
- dbt_platform_helper-10.11.2.dist-info/LICENSE,sha256=dP79lN73--7LMApnankTGLqDbImXg8iYFqWgnExGkGk,1090
100
- dbt_platform_helper-10.11.2.dist-info/METADATA,sha256=lA9wUd7Bp-AE9Xj3bjVp0xzTYQgSBnjcUNawTnj9bfk,3127
101
- dbt_platform_helper-10.11.2.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
102
- dbt_platform_helper-10.11.2.dist-info/entry_points.txt,sha256=QhbY8F434A-onsg0-FsdMd2U6HKh6Q7yCFFZrGUh5-M,67
103
- dbt_platform_helper-10.11.2.dist-info/RECORD,,
96
+ dbt_platform_helper/utils/validation.py,sha256=ZQMKPleuBsUr4XZ-fl_9AA_-NVHzH1Ol7YD-0vzKFhc,23801
97
+ dbt_platform_helper/utils/versioning.py,sha256=IBxdocJ8ZyJib38d1ja87tTuFE0iJ4npaDcAHQAKQ58,10825
98
+ platform_helper.py,sha256=1lvPwynKODyi2U-ePKzJyFwRdKPs6_6zAYUPDYzDKMo,2300
99
+ dbt_platform_helper-10.11.3.dist-info/LICENSE,sha256=dP79lN73--7LMApnankTGLqDbImXg8iYFqWgnExGkGk,1090
100
+ dbt_platform_helper-10.11.3.dist-info/METADATA,sha256=gOy4d4Ms2qrec-Pb_YOn0hU7KTmHRftUqma2mo2isTI,3127
101
+ dbt_platform_helper-10.11.3.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
102
+ dbt_platform_helper-10.11.3.dist-info/entry_points.txt,sha256=QhbY8F434A-onsg0-FsdMd2U6HKh6Q7yCFFZrGUh5-M,67
103
+ dbt_platform_helper-10.11.3.dist-info/RECORD,,
platform_helper.py CHANGED
@@ -20,7 +20,7 @@ from dbt_platform_helper.commands.generate import generate as generate_commands
20
20
  from dbt_platform_helper.commands.notify import notify as notify_commands
21
21
  from dbt_platform_helper.commands.pipeline import pipeline as pipeline_commands
22
22
  from dbt_platform_helper.commands.secrets import secrets as secrets_commands
23
- from dbt_platform_helper.commands.version import version as version_commands
23
+ from dbt_platform_helper.commands.version import VersionCommand
24
24
  from dbt_platform_helper.utils.click import ClickDocOptGroup
25
25
 
26
26
 
@@ -47,7 +47,7 @@ platform_helper.add_command(pipeline_commands)
47
47
  platform_helper.add_command(secrets_commands)
48
48
  platform_helper.add_command(notify_commands)
49
49
  platform_helper.add_command(database_commands)
50
- platform_helper.add_command(version_commands)
50
+ platform_helper.add_command(VersionCommand().command_group)
51
51
 
52
52
  if __name__ == "__main__":
53
53
  platform_helper()