entropy-data 0.3.22__tar.gz → 0.3.23__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.
- {entropy_data-0.3.22 → entropy_data-0.3.23}/CHANGELOG.md +4 -0
- {entropy_data-0.3.22 → entropy_data-0.3.23}/PKG-INFO +8 -1
- {entropy_data-0.3.22 → entropy_data-0.3.23}/README.md +7 -0
- {entropy_data-0.3.22 → entropy_data-0.3.23}/pyproject.toml +1 -1
- entropy_data-0.3.23/src/entropy_data/commands/semantic_branches.py +239 -0
- {entropy_data-0.3.22 → entropy_data-0.3.23}/src/entropy_data/commands/semantics.py +7 -0
- {entropy_data-0.3.22 → entropy_data-0.3.23}/src/entropy_data/output.py +12 -0
- entropy_data-0.3.23/tests/commands/test_semantic_branches.py +163 -0
- {entropy_data-0.3.22 → entropy_data-0.3.23}/.dockerignore +0 -0
- {entropy_data-0.3.22 → entropy_data-0.3.23}/.editorconfig +0 -0
- {entropy_data-0.3.22 → entropy_data-0.3.23}/.github/dependabot.yml +0 -0
- {entropy_data-0.3.22 → entropy_data-0.3.23}/.github/pull_request_template.md +0 -0
- {entropy_data-0.3.22 → entropy_data-0.3.23}/.github/workflows/ci.yaml +0 -0
- {entropy_data-0.3.22 → entropy_data-0.3.23}/.github/workflows/dependabot-auto-merge.yaml +0 -0
- {entropy_data-0.3.22 → entropy_data-0.3.23}/.github/workflows/release.yaml +0 -0
- {entropy_data-0.3.22 → entropy_data-0.3.23}/.gitignore +0 -0
- {entropy_data-0.3.22 → entropy_data-0.3.23}/.pre-commit-config.yaml +0 -0
- {entropy_data-0.3.22 → entropy_data-0.3.23}/CLAUDE.md +0 -0
- {entropy_data-0.3.22 → entropy_data-0.3.23}/Dockerfile +0 -0
- {entropy_data-0.3.22 → entropy_data-0.3.23}/LICENSE +0 -0
- {entropy_data-0.3.22 → entropy_data-0.3.23}/docs/apply-command-plan.md +0 -0
- {entropy_data-0.3.22 → entropy_data-0.3.23}/release +0 -0
- {entropy_data-0.3.22 → entropy_data-0.3.23}/src/entropy_data/__init__.py +0 -0
- {entropy_data-0.3.22 → entropy_data-0.3.23}/src/entropy_data/__main__.py +0 -0
- {entropy_data-0.3.22 → entropy_data-0.3.23}/src/entropy_data/cli.py +0 -0
- {entropy_data-0.3.22 → entropy_data-0.3.23}/src/entropy_data/client.py +0 -0
- {entropy_data-0.3.22 → entropy_data-0.3.23}/src/entropy_data/commands/__init__.py +0 -0
- {entropy_data-0.3.22 → entropy_data-0.3.23}/src/entropy_data/commands/access.py +0 -0
- {entropy_data-0.3.22 → entropy_data-0.3.23}/src/entropy_data/commands/api_keys.py +0 -0
- {entropy_data-0.3.22 → entropy_data-0.3.23}/src/entropy_data/commands/assets.py +0 -0
- {entropy_data-0.3.22 → entropy_data-0.3.23}/src/entropy_data/commands/certifications.py +0 -0
- {entropy_data-0.3.22 → entropy_data-0.3.23}/src/entropy_data/commands/classifications.py +0 -0
- {entropy_data-0.3.22 → entropy_data-0.3.23}/src/entropy_data/commands/connection.py +0 -0
- {entropy_data-0.3.22 → entropy_data-0.3.23}/src/entropy_data/commands/connectors.py +0 -0
- {entropy_data-0.3.22 → entropy_data-0.3.23}/src/entropy_data/commands/costs.py +0 -0
- {entropy_data-0.3.22 → entropy_data-0.3.23}/src/entropy_data/commands/datacontract_branches.py +0 -0
- {entropy_data-0.3.22 → entropy_data-0.3.23}/src/entropy_data/commands/datacontracts.py +0 -0
- {entropy_data-0.3.22 → entropy_data-0.3.23}/src/entropy_data/commands/dataproducts.py +0 -0
- {entropy_data-0.3.22 → entropy_data-0.3.23}/src/entropy_data/commands/definitions.py +0 -0
- {entropy_data-0.3.22 → entropy_data-0.3.23}/src/entropy_data/commands/events.py +0 -0
- {entropy_data-0.3.22 → entropy_data-0.3.23}/src/entropy_data/commands/example_data.py +0 -0
- {entropy_data-0.3.22 → entropy_data-0.3.23}/src/entropy_data/commands/git_credentials.py +0 -0
- {entropy_data-0.3.22 → entropy_data-0.3.23}/src/entropy_data/commands/gitconnections.py +0 -0
- {entropy_data-0.3.22 → entropy_data-0.3.23}/src/entropy_data/commands/import_export.py +0 -0
- {entropy_data-0.3.22 → entropy_data-0.3.23}/src/entropy_data/commands/integrations.py +0 -0
- {entropy_data-0.3.22 → entropy_data-0.3.23}/src/entropy_data/commands/lineage.py +0 -0
- {entropy_data-0.3.22 → entropy_data-0.3.23}/src/entropy_data/commands/notification_channels.py +0 -0
- {entropy_data-0.3.22 → entropy_data-0.3.23}/src/entropy_data/commands/organization.py +0 -0
- {entropy_data-0.3.22 → entropy_data-0.3.23}/src/entropy_data/commands/policies.py +0 -0
- {entropy_data-0.3.22 → entropy_data-0.3.23}/src/entropy_data/commands/schemas.py +0 -0
- {entropy_data-0.3.22 → entropy_data-0.3.23}/src/entropy_data/commands/search.py +0 -0
- {entropy_data-0.3.22 → entropy_data-0.3.23}/src/entropy_data/commands/settings.py +0 -0
- {entropy_data-0.3.22 → entropy_data-0.3.23}/src/entropy_data/commands/sourcesystems.py +0 -0
- {entropy_data-0.3.22 → entropy_data-0.3.23}/src/entropy_data/commands/sync.py +0 -0
- {entropy_data-0.3.22 → entropy_data-0.3.23}/src/entropy_data/commands/tags.py +0 -0
- {entropy_data-0.3.22 → entropy_data-0.3.23}/src/entropy_data/commands/teams.py +0 -0
- {entropy_data-0.3.22 → entropy_data-0.3.23}/src/entropy_data/commands/test_results.py +0 -0
- {entropy_data-0.3.22 → entropy_data-0.3.23}/src/entropy_data/commands/usage.py +0 -0
- {entropy_data-0.3.22 → entropy_data-0.3.23}/src/entropy_data/config.py +0 -0
- {entropy_data-0.3.22 → entropy_data-0.3.23}/src/entropy_data/resources.py +0 -0
- {entropy_data-0.3.22 → entropy_data-0.3.23}/src/entropy_data/sync.py +0 -0
- {entropy_data-0.3.22 → entropy_data-0.3.23}/src/entropy_data/util.py +0 -0
- {entropy_data-0.3.22 → entropy_data-0.3.23}/tests/__init__.py +0 -0
- {entropy_data-0.3.22 → entropy_data-0.3.23}/tests/commands/__init__.py +0 -0
- {entropy_data-0.3.22 → entropy_data-0.3.23}/tests/commands/test_access_request.py +0 -0
- {entropy_data-0.3.22 → entropy_data-0.3.23}/tests/commands/test_api_keys.py +0 -0
- {entropy_data-0.3.22 → entropy_data-0.3.23}/tests/commands/test_assets.py +0 -0
- {entropy_data-0.3.22 → entropy_data-0.3.23}/tests/commands/test_classifications.py +0 -0
- {entropy_data-0.3.22 → entropy_data-0.3.23}/tests/commands/test_connection.py +0 -0
- {entropy_data-0.3.22 → entropy_data-0.3.23}/tests/commands/test_connectors.py +0 -0
- {entropy_data-0.3.22 → entropy_data-0.3.23}/tests/commands/test_costs.py +0 -0
- {entropy_data-0.3.22 → entropy_data-0.3.23}/tests/commands/test_datacontract_branches.py +0 -0
- {entropy_data-0.3.22 → entropy_data-0.3.23}/tests/commands/test_datacontracts.py +0 -0
- {entropy_data-0.3.22 → entropy_data-0.3.23}/tests/commands/test_dataproducts.py +0 -0
- {entropy_data-0.3.22 → entropy_data-0.3.23}/tests/commands/test_email_templates.py +0 -0
- {entropy_data-0.3.22 → entropy_data-0.3.23}/tests/commands/test_git_credentials.py +0 -0
- {entropy_data-0.3.22 → entropy_data-0.3.23}/tests/commands/test_gitconnections.py +0 -0
- {entropy_data-0.3.22 → entropy_data-0.3.23}/tests/commands/test_import_export.py +0 -0
- {entropy_data-0.3.22 → entropy_data-0.3.23}/tests/commands/test_integrations.py +0 -0
- {entropy_data-0.3.22 → entropy_data-0.3.23}/tests/commands/test_lineage.py +0 -0
- {entropy_data-0.3.22 → entropy_data-0.3.23}/tests/commands/test_notification_channels.py +0 -0
- {entropy_data-0.3.22 → entropy_data-0.3.23}/tests/commands/test_organization.py +0 -0
- {entropy_data-0.3.22 → entropy_data-0.3.23}/tests/commands/test_policies.py +0 -0
- {entropy_data-0.3.22 → entropy_data-0.3.23}/tests/commands/test_schemas.py +0 -0
- {entropy_data-0.3.22 → entropy_data-0.3.23}/tests/commands/test_semantics.py +0 -0
- {entropy_data-0.3.22 → entropy_data-0.3.23}/tests/commands/test_settings.py +0 -0
- {entropy_data-0.3.22 → entropy_data-0.3.23}/tests/commands/test_tags.py +0 -0
- {entropy_data-0.3.22 → entropy_data-0.3.23}/tests/commands/test_team_roles.py +0 -0
- {entropy_data-0.3.22 → entropy_data-0.3.23}/tests/commands/test_teams.py +0 -0
- {entropy_data-0.3.22 → entropy_data-0.3.23}/tests/commands/test_test_results.py +0 -0
- {entropy_data-0.3.22 → entropy_data-0.3.23}/tests/commands/test_usage.py +0 -0
- {entropy_data-0.3.22 → entropy_data-0.3.23}/tests/conftest.py +0 -0
- {entropy_data-0.3.22 → entropy_data-0.3.23}/tests/test_cli.py +0 -0
- {entropy_data-0.3.22 → entropy_data-0.3.23}/tests/test_client.py +0 -0
- {entropy_data-0.3.22 → entropy_data-0.3.23}/tests/test_config.py +0 -0
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.3.23]
|
|
4
|
+
|
|
5
|
+
- Add `entropy-data semantics branches` to work on branches of a semantic namespace: `list`, `create`, `get`, `put` (replace the branch with an OSI ontology YAML document, sent as written), `yaml`, `changes` (what the branch changes against the namespace, one entry per concept), `rebase`, `merge` and `delete`. `merge` lands the branch, or — where the namespace's git branch only takes reviewed changes — prints the pull/merge request opened from it, leaving the branch open. Requires semantic branches on the instance (entropy-data#1665).
|
|
6
|
+
|
|
3
7
|
## [0.3.22]
|
|
4
8
|
|
|
5
9
|
- Add `entropy-data settings email-templates get|put` to manage the organization's email templates as one document: every email type with its enabled state and the effective subject and body per language, each marked as built-in or customized. `put` replaces the whole setup — omitted types and languages revert to the built-in email, and wording identical to the built-in text stays uncustomized, so a `get` written back unchanged customizes nothing. Requires `GET`/`PUT /api/settings/email-templates` on the instance (entropy-data#1705).
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: entropy-data
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.23
|
|
4
4
|
Summary: CLI for Entropy Data
|
|
5
5
|
Project-URL: Homepage, https://entropy-data.com
|
|
6
6
|
Project-URL: Documentation, https://docs.entropy-data.com
|
|
@@ -121,6 +121,12 @@ entropy-data datacontracts branches create orders add-status
|
|
|
121
121
|
entropy-data datacontracts branches put orders add-status --file orders.yaml
|
|
122
122
|
entropy-data datacontracts test orders --branch add-status
|
|
123
123
|
entropy-data datacontracts branches merge orders add-status --version 1.1.0
|
|
124
|
+
|
|
125
|
+
# Propose ontology changes on a branch of a semantic namespace, then merge them
|
|
126
|
+
entropy-data semantics branches create sales add-credit-limit
|
|
127
|
+
entropy-data semantics branches put sales add-credit-limit --file ontology.yaml
|
|
128
|
+
entropy-data semantics branches changes sales add-credit-limit
|
|
129
|
+
entropy-data semantics branches merge sales add-credit-limit
|
|
124
130
|
```
|
|
125
131
|
|
|
126
132
|
## Commands
|
|
@@ -154,6 +160,7 @@ entropy-data [--version] [--connection NAME] [--output table|json|yaml] [--debug
|
|
|
154
160
|
schemas get
|
|
155
161
|
search query
|
|
156
162
|
semantics namespaces ... | concepts ... | relationships ... | search
|
|
163
|
+
branches list | create | get | put | yaml | changes | rebase | merge | delete
|
|
157
164
|
usage list | submit | delete
|
|
158
165
|
export dir
|
|
159
166
|
apply dir [--include] [--exclude] [--prune] [--dry-run]
|
|
@@ -88,6 +88,12 @@ entropy-data datacontracts branches create orders add-status
|
|
|
88
88
|
entropy-data datacontracts branches put orders add-status --file orders.yaml
|
|
89
89
|
entropy-data datacontracts test orders --branch add-status
|
|
90
90
|
entropy-data datacontracts branches merge orders add-status --version 1.1.0
|
|
91
|
+
|
|
92
|
+
# Propose ontology changes on a branch of a semantic namespace, then merge them
|
|
93
|
+
entropy-data semantics branches create sales add-credit-limit
|
|
94
|
+
entropy-data semantics branches put sales add-credit-limit --file ontology.yaml
|
|
95
|
+
entropy-data semantics branches changes sales add-credit-limit
|
|
96
|
+
entropy-data semantics branches merge sales add-credit-limit
|
|
91
97
|
```
|
|
92
98
|
|
|
93
99
|
## Commands
|
|
@@ -121,6 +127,7 @@ entropy-data [--version] [--connection NAME] [--output table|json|yaml] [--debug
|
|
|
121
127
|
schemas get
|
|
122
128
|
search query
|
|
123
129
|
semantics namespaces ... | concepts ... | relationships ... | search
|
|
130
|
+
branches list | create | get | put | yaml | changes | rebase | merge | delete
|
|
124
131
|
usage list | submit | delete
|
|
125
132
|
export dir
|
|
126
133
|
apply dir [--include] [--exclude] [--prune] [--dry-run]
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
"""Branches of a semantic namespace: cut, author, review and merge a draft of its OSI ontology."""
|
|
2
|
+
|
|
3
|
+
import sys
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
from typing import Annotated, Optional
|
|
6
|
+
|
|
7
|
+
import typer
|
|
8
|
+
|
|
9
|
+
from entropy_data.output import OutputFormat, print_data, print_resource, print_resource_list, print_success
|
|
10
|
+
|
|
11
|
+
branches_app = typer.Typer(no_args_is_help=True)
|
|
12
|
+
RESOURCE_TYPE = "semantic-branches"
|
|
13
|
+
CHANGES_TYPE = "semantic-branch-changes"
|
|
14
|
+
|
|
15
|
+
NAMESPACE_HELP = "Namespace the branch is cut from."
|
|
16
|
+
BRANCH_HELP = "Branch name."
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def branches_path(namespace: str) -> str:
|
|
20
|
+
from entropy_data.client import _validate_resource_id
|
|
21
|
+
|
|
22
|
+
_validate_resource_id(namespace)
|
|
23
|
+
return f"semantics/experimental/namespaces/{namespace}/branches"
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def branch_path(namespace: str, branch: str) -> str:
|
|
27
|
+
from entropy_data.client import _validate_resource_id
|
|
28
|
+
|
|
29
|
+
_validate_resource_id(branch)
|
|
30
|
+
return f"{branches_path(namespace)}/{branch}"
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def read_text(file: Path) -> str:
|
|
34
|
+
if str(file) == "-":
|
|
35
|
+
return sys.stdin.read()
|
|
36
|
+
return file.read_text()
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
@branches_app.command("list")
|
|
40
|
+
def list_branches(
|
|
41
|
+
namespace: Annotated[str, typer.Argument(help=NAMESPACE_HELP)],
|
|
42
|
+
output: Annotated[Optional[OutputFormat], typer.Option("--output", "-o", help="Output format.")] = None,
|
|
43
|
+
) -> None:
|
|
44
|
+
"""List the branches cut from a namespace."""
|
|
45
|
+
from entropy_data.cli import get_client, get_output_format, handle_error
|
|
46
|
+
|
|
47
|
+
fmt = output or get_output_format()
|
|
48
|
+
try:
|
|
49
|
+
client = get_client()
|
|
50
|
+
data, _ = client.list_resources(branches_path(namespace))
|
|
51
|
+
print_resource_list(data, RESOURCE_TYPE, fmt, title=f"Branches of {namespace}")
|
|
52
|
+
except Exception as e:
|
|
53
|
+
handle_error(e)
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
@branches_app.command("create")
|
|
57
|
+
def create_branch(
|
|
58
|
+
namespace: Annotated[str, typer.Argument(help=NAMESPACE_HELP)],
|
|
59
|
+
branch: Annotated[str, typer.Argument(help=BRANCH_HELP)],
|
|
60
|
+
output: Annotated[Optional[OutputFormat], typer.Option("--output", "-o", help="Output format.")] = None,
|
|
61
|
+
) -> None:
|
|
62
|
+
"""Cut a branch from a namespace. Cutting an existing name returns that branch."""
|
|
63
|
+
from entropy_data.cli import get_client, get_output_format, handle_error
|
|
64
|
+
from entropy_data.client import REQUEST_TIMEOUT, _raise_for_status
|
|
65
|
+
|
|
66
|
+
fmt = output or get_output_format()
|
|
67
|
+
try:
|
|
68
|
+
client = get_client()
|
|
69
|
+
response = client.session.put(
|
|
70
|
+
f"{client.base_url}/api/{branch_path(namespace, branch)}", timeout=REQUEST_TIMEOUT
|
|
71
|
+
)
|
|
72
|
+
_raise_for_status(response)
|
|
73
|
+
if fmt == OutputFormat.table:
|
|
74
|
+
print_success(f"Branch '{branch}' of namespace '{namespace}' created.")
|
|
75
|
+
print_resource(response.json(), RESOURCE_TYPE, fmt)
|
|
76
|
+
except Exception as e:
|
|
77
|
+
handle_error(e)
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
@branches_app.command("get")
|
|
81
|
+
def get_branch(
|
|
82
|
+
namespace: Annotated[str, typer.Argument(help=NAMESPACE_HELP)],
|
|
83
|
+
branch: Annotated[str, typer.Argument(help=BRANCH_HELP)],
|
|
84
|
+
output: Annotated[Optional[OutputFormat], typer.Option("--output", "-o", help="Output format.")] = None,
|
|
85
|
+
) -> None:
|
|
86
|
+
"""Show a branch: whether the namespace moved since, its conflicts, and any open pull request."""
|
|
87
|
+
from entropy_data.cli import get_client, get_output_format, handle_error
|
|
88
|
+
|
|
89
|
+
fmt = output or get_output_format()
|
|
90
|
+
try:
|
|
91
|
+
client = get_client()
|
|
92
|
+
data = client.get_resource(branches_path(namespace), branch)
|
|
93
|
+
print_resource(data, RESOURCE_TYPE, fmt)
|
|
94
|
+
except Exception as e:
|
|
95
|
+
handle_error(e)
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
@branches_app.command("delete")
|
|
99
|
+
def delete_branch(
|
|
100
|
+
namespace: Annotated[str, typer.Argument(help=NAMESPACE_HELP)],
|
|
101
|
+
branch: Annotated[str, typer.Argument(help=BRANCH_HELP)],
|
|
102
|
+
) -> None:
|
|
103
|
+
"""Delete a branch and everything authored on it. The namespace is untouched."""
|
|
104
|
+
from entropy_data.cli import get_client, handle_error
|
|
105
|
+
|
|
106
|
+
try:
|
|
107
|
+
client = get_client()
|
|
108
|
+
client.delete_resource(branches_path(namespace), branch)
|
|
109
|
+
print_success(f"Branch '{branch}' of namespace '{namespace}' deleted.")
|
|
110
|
+
except Exception as e:
|
|
111
|
+
handle_error(e)
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
@branches_app.command("yaml")
|
|
115
|
+
def yaml_branch(
|
|
116
|
+
namespace: Annotated[str, typer.Argument(help=NAMESPACE_HELP)],
|
|
117
|
+
branch: Annotated[str, typer.Argument(help=BRANCH_HELP)],
|
|
118
|
+
out_file: Annotated[
|
|
119
|
+
Optional[Path],
|
|
120
|
+
typer.Option("--file", "-f", help="Write YAML to this file. Defaults to stdout."),
|
|
121
|
+
] = None,
|
|
122
|
+
) -> None:
|
|
123
|
+
"""Get the branch as one OSI ontology YAML document."""
|
|
124
|
+
from entropy_data.cli import get_client, handle_error
|
|
125
|
+
from entropy_data.client import REQUEST_TIMEOUT, _raise_for_status
|
|
126
|
+
|
|
127
|
+
try:
|
|
128
|
+
client = get_client()
|
|
129
|
+
response = client.session.get(
|
|
130
|
+
f"{client.base_url}/api/{branch_path(namespace, branch)}/ontology.yaml",
|
|
131
|
+
headers={"Accept": "application/yaml"},
|
|
132
|
+
timeout=REQUEST_TIMEOUT,
|
|
133
|
+
)
|
|
134
|
+
_raise_for_status(response)
|
|
135
|
+
if out_file is not None:
|
|
136
|
+
out_file.write_text(response.text)
|
|
137
|
+
print_success(f"Branch '{branch}' of namespace '{namespace}' written to {out_file}.")
|
|
138
|
+
else:
|
|
139
|
+
print(response.text)
|
|
140
|
+
except Exception as e:
|
|
141
|
+
handle_error(e)
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
@branches_app.command("put")
|
|
145
|
+
def put_branch(
|
|
146
|
+
namespace: Annotated[str, typer.Argument(help=NAMESPACE_HELP)],
|
|
147
|
+
branch: Annotated[str, typer.Argument(help=BRANCH_HELP)],
|
|
148
|
+
file: Annotated[Path, typer.Option("--file", "-f", help="OSI ontology YAML file (use - for stdin).")] = ...,
|
|
149
|
+
) -> None:
|
|
150
|
+
"""Replace the branch with an OSI ontology YAML document.
|
|
151
|
+
|
|
152
|
+
The document is the branch's complete state: a concept or relationship it leaves out is removed
|
|
153
|
+
from the branch. The namespace itself is untouched until the branch is merged.
|
|
154
|
+
"""
|
|
155
|
+
from entropy_data.cli import get_client, handle_error
|
|
156
|
+
from entropy_data.client import REQUEST_TIMEOUT, _raise_for_status
|
|
157
|
+
|
|
158
|
+
try:
|
|
159
|
+
content = read_text(file)
|
|
160
|
+
client = get_client()
|
|
161
|
+
response = client.session.put(
|
|
162
|
+
f"{client.base_url}/api/{branch_path(namespace, branch)}/ontology.yaml",
|
|
163
|
+
data=content.encode("utf-8"),
|
|
164
|
+
headers={"Content-Type": "application/yaml"},
|
|
165
|
+
timeout=REQUEST_TIMEOUT,
|
|
166
|
+
)
|
|
167
|
+
_raise_for_status(response)
|
|
168
|
+
print_success(f"Branch '{branch}' of namespace '{namespace}' updated.")
|
|
169
|
+
except Exception as e:
|
|
170
|
+
handle_error(e)
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
@branches_app.command("changes")
|
|
174
|
+
def changes_of_branch(
|
|
175
|
+
namespace: Annotated[str, typer.Argument(help=NAMESPACE_HELP)],
|
|
176
|
+
branch: Annotated[str, typer.Argument(help=BRANCH_HELP)],
|
|
177
|
+
output: Annotated[Optional[OutputFormat], typer.Option("--output", "-o", help="Output format.")] = None,
|
|
178
|
+
) -> None:
|
|
179
|
+
"""List what the branch changes against the namespace, one entry per concept."""
|
|
180
|
+
from entropy_data.cli import get_client, get_output_format, handle_error
|
|
181
|
+
|
|
182
|
+
fmt = output or get_output_format()
|
|
183
|
+
try:
|
|
184
|
+
client = get_client()
|
|
185
|
+
data, _ = client.list_resources(f"{branch_path(namespace, branch)}/changes")
|
|
186
|
+
print_resource_list(data, CHANGES_TYPE, fmt, title=f"Changes on {branch}")
|
|
187
|
+
except Exception as e:
|
|
188
|
+
handle_error(e)
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
@branches_app.command("rebase")
|
|
192
|
+
def rebase_branch(
|
|
193
|
+
namespace: Annotated[str, typer.Argument(help=NAMESPACE_HELP)],
|
|
194
|
+
branch: Annotated[str, typer.Argument(help=BRANCH_HELP)],
|
|
195
|
+
output: Annotated[Optional[OutputFormat], typer.Option("--output", "-o", help="Output format.")] = None,
|
|
196
|
+
) -> None:
|
|
197
|
+
"""Update the branch from the namespace. Conflicts are reported and resolved in the UI."""
|
|
198
|
+
from entropy_data.cli import get_client, get_output_format, handle_error
|
|
199
|
+
|
|
200
|
+
fmt = output or get_output_format()
|
|
201
|
+
try:
|
|
202
|
+
client = get_client()
|
|
203
|
+
data = client.post_action_json(branches_path(namespace), branch, "rebase")
|
|
204
|
+
if fmt == OutputFormat.table:
|
|
205
|
+
print_success(f"Branch '{branch}' updated from namespace '{namespace}'.")
|
|
206
|
+
print_resource(data, RESOURCE_TYPE, fmt)
|
|
207
|
+
except Exception as e:
|
|
208
|
+
handle_error(e)
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
@branches_app.command("merge")
|
|
212
|
+
def merge_branch(
|
|
213
|
+
namespace: Annotated[str, typer.Argument(help=NAMESPACE_HELP)],
|
|
214
|
+
branch: Annotated[str, typer.Argument(help=BRANCH_HELP)],
|
|
215
|
+
output: Annotated[Optional[OutputFormat], typer.Option("--output", "-o", help="Output format.")] = None,
|
|
216
|
+
) -> None:
|
|
217
|
+
"""Merge the branch: land it on the namespace, or open a pull request where git requires review."""
|
|
218
|
+
from entropy_data.cli import get_client, get_output_format, handle_error
|
|
219
|
+
from entropy_data.client import REQUEST_TIMEOUT, _raise_for_status
|
|
220
|
+
|
|
221
|
+
fmt = output or get_output_format()
|
|
222
|
+
try:
|
|
223
|
+
client = get_client()
|
|
224
|
+
response = client.session.post(
|
|
225
|
+
f"{client.base_url}/api/{branch_path(namespace, branch)}/merge", timeout=REQUEST_TIMEOUT
|
|
226
|
+
)
|
|
227
|
+
_raise_for_status(response)
|
|
228
|
+
if response.status_code == 204:
|
|
229
|
+
print_success(f"Branch '{branch}' merged into namespace '{namespace}'.")
|
|
230
|
+
return
|
|
231
|
+
# 200: the branch stays open, a pull/merge request was opened from it.
|
|
232
|
+
data = response.json()
|
|
233
|
+
if fmt == OutputFormat.table:
|
|
234
|
+
print_success(f"Request opened for branch '{branch}'. The branch stays open.")
|
|
235
|
+
print_data(data, OutputFormat.json)
|
|
236
|
+
else:
|
|
237
|
+
print_data(data, fmt)
|
|
238
|
+
except Exception as e:
|
|
239
|
+
handle_error(e)
|
|
@@ -303,6 +303,13 @@ def search_concepts(
|
|
|
303
303
|
handle_error(e)
|
|
304
304
|
|
|
305
305
|
|
|
306
|
+
from entropy_data.commands.semantic_branches import branches_app # noqa: E402
|
|
307
|
+
|
|
306
308
|
semantics_app.add_typer(namespaces_app, name="namespaces", help="Manage semantic namespaces.")
|
|
307
309
|
semantics_app.add_typer(concepts_app, name="concepts", help="Manage semantic concepts.")
|
|
308
310
|
semantics_app.add_typer(relationships_app, name="relationships", help="Manage semantic relationships.")
|
|
311
|
+
semantics_app.add_typer(
|
|
312
|
+
branches_app,
|
|
313
|
+
name="branches",
|
|
314
|
+
help="Branches of a semantic namespace: cut, author, review and merge a draft.",
|
|
315
|
+
)
|
|
@@ -71,6 +71,18 @@ RESOURCE_COLUMNS: dict[str, list[tuple[str, str]]] = {
|
|
|
71
71
|
("Conflicted", "conflicted"),
|
|
72
72
|
],
|
|
73
73
|
"datacontract-branch-changes": [("Element", "key"), ("Op", "op"), ("Impact", "impact")],
|
|
74
|
+
"semantic-branches": [
|
|
75
|
+
("Name", "name"),
|
|
76
|
+
("Namespace", "namespace"),
|
|
77
|
+
("Behind", "behind_target"),
|
|
78
|
+
("Conflicted", "conflicted"),
|
|
79
|
+
],
|
|
80
|
+
"semantic-branch-changes": [
|
|
81
|
+
("Concept", "external_id"),
|
|
82
|
+
("Type", "element_type"),
|
|
83
|
+
("Op", "op"),
|
|
84
|
+
("Impact", "impact"),
|
|
85
|
+
],
|
|
74
86
|
"events": [("ID", "id"), ("Type", "type"), ("Subject", "subject"), ("Time", "time")],
|
|
75
87
|
"costs": [("ID", "id"), ("Data Product", "dataProductId"), ("Amount", "amount"), ("Currency", "currency")],
|
|
76
88
|
"assets": [
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
"""Tests for the semantic namespace branches commands."""
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
|
|
5
|
+
import pytest
|
|
6
|
+
import responses
|
|
7
|
+
from typer.testing import CliRunner
|
|
8
|
+
|
|
9
|
+
import entropy_data.config as cfg
|
|
10
|
+
from entropy_data.cli import app
|
|
11
|
+
|
|
12
|
+
runner = CliRunner()
|
|
13
|
+
BASE_URL = "https://api.entropy-data.com"
|
|
14
|
+
BRANCHES = f"{BASE_URL}/api/semantics/experimental/namespaces/sales/branches"
|
|
15
|
+
|
|
16
|
+
BRANCH = {
|
|
17
|
+
"name": "add-credit-limit",
|
|
18
|
+
"namespace": "sales",
|
|
19
|
+
"branch_namespace": "branch-sales-add-credit-limit",
|
|
20
|
+
"behind_target": False,
|
|
21
|
+
"conflicted": False,
|
|
22
|
+
"conflicts": [],
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
YAML_BODY = """version: 1.0.0
|
|
26
|
+
name: sales
|
|
27
|
+
ontology:
|
|
28
|
+
- concept:
|
|
29
|
+
id: credit-limit
|
|
30
|
+
name: Credit Limit
|
|
31
|
+
type: ValueType
|
|
32
|
+
"""
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
@pytest.fixture(autouse=True)
|
|
36
|
+
def api_key(monkeypatch, tmp_path):
|
|
37
|
+
monkeypatch.setattr(cfg, "CONFIG_FILE", tmp_path / "config.toml")
|
|
38
|
+
monkeypatch.setenv("ENTROPY_DATA_API_KEY", "test-key")
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
@responses.activate
|
|
42
|
+
def test_branches_list_as_table_and_json():
|
|
43
|
+
responses.add(responses.GET, BRANCHES, json=[BRANCH], status=200)
|
|
44
|
+
result = runner.invoke(app, ["semantics", "branches", "list", "sales"])
|
|
45
|
+
assert result.exit_code == 0
|
|
46
|
+
assert "add-credit-limit" in result.output
|
|
47
|
+
|
|
48
|
+
result = runner.invoke(app, ["semantics", "branches", "list", "sales", "-o", "json"])
|
|
49
|
+
assert result.exit_code == 0
|
|
50
|
+
assert json.loads(result.output)[0]["branch_namespace"] == "branch-sales-add-credit-limit"
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
@responses.activate
|
|
54
|
+
def test_branches_create_get_delete():
|
|
55
|
+
responses.add(responses.PUT, f"{BRANCHES}/add-credit-limit", json=BRANCH, status=200)
|
|
56
|
+
responses.add(responses.GET, f"{BRANCHES}/add-credit-limit", json=BRANCH, status=200)
|
|
57
|
+
responses.add(responses.DELETE, f"{BRANCHES}/add-credit-limit", status=204)
|
|
58
|
+
|
|
59
|
+
result = runner.invoke(app, ["semantics", "branches", "create", "sales", "add-credit-limit"])
|
|
60
|
+
assert result.exit_code == 0
|
|
61
|
+
assert "created" in result.output
|
|
62
|
+
|
|
63
|
+
result = runner.invoke(app, ["semantics", "branches", "get", "sales", "add-credit-limit", "-o", "json"])
|
|
64
|
+
assert result.exit_code == 0
|
|
65
|
+
assert json.loads(result.output)["namespace"] == "sales"
|
|
66
|
+
|
|
67
|
+
result = runner.invoke(app, ["semantics", "branches", "delete", "sales", "add-credit-limit"])
|
|
68
|
+
assert result.exit_code == 0
|
|
69
|
+
assert "deleted" in result.output
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
@responses.activate
|
|
73
|
+
def test_branches_yaml_and_put(tmp_path):
|
|
74
|
+
responses.add(
|
|
75
|
+
responses.GET,
|
|
76
|
+
f"{BRANCHES}/add-credit-limit/ontology.yaml",
|
|
77
|
+
body=YAML_BODY,
|
|
78
|
+
content_type="application/yaml",
|
|
79
|
+
status=200,
|
|
80
|
+
)
|
|
81
|
+
responses.add(responses.PUT, f"{BRANCHES}/add-credit-limit/ontology.yaml", status=200)
|
|
82
|
+
|
|
83
|
+
result = runner.invoke(app, ["semantics", "branches", "yaml", "sales", "add-credit-limit"])
|
|
84
|
+
assert result.exit_code == 0
|
|
85
|
+
assert "id: credit-limit" in result.output
|
|
86
|
+
assert responses.calls[0].request.headers["Accept"] == "application/yaml"
|
|
87
|
+
|
|
88
|
+
edited = tmp_path / "sales.yaml"
|
|
89
|
+
edited.write_text(YAML_BODY + "# kept as written\n")
|
|
90
|
+
result = runner.invoke(app, ["semantics", "branches", "put", "sales", "add-credit-limit", "--file", str(edited)])
|
|
91
|
+
assert result.exit_code == 0
|
|
92
|
+
assert "updated" in result.output
|
|
93
|
+
put = responses.calls[1].request
|
|
94
|
+
assert put.headers["Content-Type"] == "application/yaml"
|
|
95
|
+
assert put.body.decode() == edited.read_text()
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
@responses.activate
|
|
99
|
+
def test_branches_changes_and_rebase():
|
|
100
|
+
changes = [
|
|
101
|
+
{
|
|
102
|
+
"external_id": "credit-limit",
|
|
103
|
+
"element_type": "ValueType",
|
|
104
|
+
"name": "Credit Limit",
|
|
105
|
+
"op": "add",
|
|
106
|
+
"impact": "additive",
|
|
107
|
+
"warnings": [],
|
|
108
|
+
"fields": [],
|
|
109
|
+
"properties": [],
|
|
110
|
+
"relationships": [],
|
|
111
|
+
}
|
|
112
|
+
]
|
|
113
|
+
responses.add(responses.GET, f"{BRANCHES}/add-credit-limit/changes", json=changes, status=200)
|
|
114
|
+
responses.add(responses.POST, f"{BRANCHES}/add-credit-limit/rebase", json=BRANCH, status=200)
|
|
115
|
+
|
|
116
|
+
result = runner.invoke(app, ["semantics", "branches", "changes", "sales", "add-credit-limit"])
|
|
117
|
+
assert result.exit_code == 0
|
|
118
|
+
assert "credit-limit" in result.output
|
|
119
|
+
assert "additive" in result.output
|
|
120
|
+
|
|
121
|
+
result = runner.invoke(app, ["semantics", "branches", "rebase", "sales", "add-credit-limit"])
|
|
122
|
+
assert result.exit_code == 0
|
|
123
|
+
assert "updated from namespace" in result.output
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
@responses.activate
|
|
127
|
+
def test_branches_merge_lands():
|
|
128
|
+
responses.add(responses.POST, f"{BRANCHES}/add-credit-limit/merge", status=204)
|
|
129
|
+
result = runner.invoke(app, ["semantics", "branches", "merge", "sales", "add-credit-limit"])
|
|
130
|
+
assert result.exit_code == 0
|
|
131
|
+
assert "merged into namespace" in result.output
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
@responses.activate
|
|
135
|
+
def test_branches_merge_opens_a_request():
|
|
136
|
+
request = {
|
|
137
|
+
"remote_id": "7",
|
|
138
|
+
"type": "pull_request",
|
|
139
|
+
"title": "Merge add-credit-limit into sales",
|
|
140
|
+
"url": "https://github.com/test/repo/pull/7",
|
|
141
|
+
"status": "open",
|
|
142
|
+
}
|
|
143
|
+
responses.add(responses.POST, f"{BRANCHES}/add-credit-limit/merge", json=request, status=200)
|
|
144
|
+
result = runner.invoke(app, ["semantics", "branches", "merge", "sales", "add-credit-limit", "-o", "json"])
|
|
145
|
+
assert result.exit_code == 0
|
|
146
|
+
assert json.loads(result.output)["url"] == "https://github.com/test/repo/pull/7"
|
|
147
|
+
|
|
148
|
+
result = runner.invoke(app, ["semantics", "branches", "merge", "sales", "add-credit-limit"])
|
|
149
|
+
assert result.exit_code == 0
|
|
150
|
+
assert "The branch stays open" in result.output
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
@responses.activate
|
|
154
|
+
def test_branches_merge_surfaces_a_conflict():
|
|
155
|
+
responses.add(
|
|
156
|
+
responses.POST,
|
|
157
|
+
f"{BRANCHES}/add-credit-limit/merge",
|
|
158
|
+
json={"message": "Branch 'add-credit-limit' has no changes to merge"},
|
|
159
|
+
status=409,
|
|
160
|
+
)
|
|
161
|
+
result = runner.invoke(app, ["semantics", "branches", "merge", "sales", "add-credit-limit"])
|
|
162
|
+
assert result.exit_code != 0
|
|
163
|
+
assert "no changes to merge" in result.output
|
|
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
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{entropy_data-0.3.22 → entropy_data-0.3.23}/src/entropy_data/commands/datacontract_branches.py
RENAMED
|
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
|
|
File without changes
|
{entropy_data-0.3.22 → entropy_data-0.3.23}/src/entropy_data/commands/notification_channels.py
RENAMED
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|