Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Images to attachments #47

Merged
merged 32 commits into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
9547978
feat: use capellambse to get diagram images
micha91 Jan 18, 2024
83e8f7a
feat: Add logging, if a diagram image is not successfully taken from …
micha91 Jan 18, 2024
549410d
feat: Move diagram cache to the capella-model cli parameter and warn …
micha91 Jan 18, 2024
59511ea
feat: modify diagram cache check for new capellambse release
micha91 Jan 18, 2024
aaa19a6
docs: Adjust documentation for pipeline configuration
micha91 Jan 19, 2024
376fda1
docs: Fix typo
ewuerger Jan 31, 2024
c1b666b
fix: tests after rebase
micha91 Feb 5, 2024
d32f072
feat: Move images to attachments - WIP
micha91 Feb 1, 2024
ba2b3a3
fix: minor errors and tests
micha91 Feb 2, 2024
57168fc
test: refactor existing tests to check for attachments for diagrams a…
micha91 Feb 2, 2024
dd456d8
test: add tests for adding and updating attachments
micha91 Feb 2, 2024
6fc3fb7
test: add tests for deleting attachments
micha91 Feb 2, 2024
ea59ea2
fix: Various minor bugs such as replacing attachment by workitemimg a…
micha91 Feb 5, 2024
c320532
fix: minor change for pylint
micha91 Feb 5, 2024
d4860f2
fix: tests
micha91 Feb 5, 2024
44f41a8
fix: black
micha91 Feb 5, 2024
6e8b638
refactor: Move diagram drawing to a common method
micha91 Feb 6, 2024
d7085d8
fix: windows tests
micha91 Feb 6, 2024
9219a7e
feat: increase png quality to 400dpi
micha91 Feb 6, 2024
5e4296c
fix: add missing workitem id
micha91 Feb 6, 2024
18801e7
fix: context diagrams png conversion does not work properly using cus…
micha91 Feb 6, 2024
fa06d08
refactor: Apply changes from code review
ewuerger Feb 6, 2024
6e0dbc9
Merge branch 'images-to-attachments' of github.com:DSD-DBS/capella-po…
ewuerger Feb 6, 2024
8e15990
refactor: Some optimizations for attachment creation
micha91 Feb 6, 2024
8e063b9
fix: remove windows pipeline
micha91 Feb 6, 2024
f57d675
fix: tests
micha91 Feb 6, 2024
53ef2c8
fix: tests and presence of work item id and remove default serialize …
micha91 Feb 6, 2024
aba9ce0
feat: set diagram max-widths to 650px for additional attributes and 8…
micha91 Feb 7, 2024
2a230c7
fix: set diagrams to 750px instead
micha91 Feb 7, 2024
9dd7e4d
feat: add html class diagram for diagrams and additional-attributes-d…
micha91 Feb 7, 2024
4908298
refactor: Reduce amount of unneeded get attachments API calls
micha91 Feb 8, 2024
b9800aa
docs: Add cairosvg dependency
micha91 Feb 12, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .github/workflows/build-test-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ jobs:
- "3.10"
- "3.11"
- "3.12"
include:
- os: windows-latest
python_version: "3.12"
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{matrix.python_version}}
Expand Down
39 changes: 10 additions & 29 deletions capella2polarion/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from __future__ import annotations

import logging
import pathlib
import typing

import capellambse
Expand Down Expand Up @@ -35,18 +34,6 @@
)
@click.option("--polarion-pat", envvar="POLARION_PAT", type=str)
@click.option("--polarion-delete-work-items", is_flag=True, default=False)
@click.option(
"--capella-diagram-cache-folder-path",
type=click.Path(
exists=True,
file_okay=False,
dir_okay=True,
readable=True,
resolve_path=True,
path_type=pathlib.Path,
),
default=None,
)
@click.option("--capella-model", type=cli_helpers.ModelCLI(), default=None)
@click.option(
"--synchronize-config",
Expand All @@ -62,18 +49,19 @@ def cli(
polarion_url: str,
polarion_pat: str,
polarion_delete_work_items: bool,
capella_diagram_cache_folder_path: pathlib.Path,
capella_model: capellambse.MelodyModel,
synchronize_config: typing.TextIO,
) -> None:
"""Synchronise data from Capella to Polarion."""
if capella_model.diagram_cache is None:
logger.warning("It's highly recommended to define a diagram cache!")

capella2polarion_cli = Capella2PolarionCli(
debug,
polarion_project_id,
polarion_url,
polarion_pat,
polarion_delete_work_items,
capella_diagram_cache_folder_path,
capella_model,
synchronize_config,
force_update,
Expand All @@ -96,28 +84,17 @@ def synchronize(ctx: click.core.Context) -> None:
"""Synchronise model elements."""
capella_to_polarion_cli: Capella2PolarionCli = ctx.obj
logger.info(
"Synchronising diagrams from diagram cache at "
"%s to Polarion project with id %s...",
str(capella_to_polarion_cli.capella_diagram_cache_folder_path),
"Synchronising model elements to Polarion project with id %s...",
capella_to_polarion_cli.polarion_params.project_id,
)
capella_to_polarion_cli.load_synchronize_config()
capella_to_polarion_cli.load_capella_diagram_cache_index()

assert (
capella_to_polarion_cli.capella_diagram_cache_index_content is not None
)

converter = model_converter.ModelConverter(
capella_to_polarion_cli.capella_model,
capella_to_polarion_cli.capella_diagram_cache_folder_path,
capella_to_polarion_cli.polarion_params.project_id,
)

converter.read_model(
capella_to_polarion_cli.config,
capella_to_polarion_cli.capella_diagram_cache_index_content,
)
converter.read_model(capella_to_polarion_cli.config)

polarion_worker = pw.CapellaPolarionWorker(
capella_to_polarion_cli.polarion_params,
Expand All @@ -133,7 +110,11 @@ def synchronize(ctx: click.core.Context) -> None:
polarion_worker.post_work_items(converter.converter_session)

# Create missing links for new work items
converter.generate_work_items(polarion_worker.polarion_data_repo, True)
converter.generate_work_items(
polarion_worker.polarion_data_repo,
generate_links=True,
generate_attachments=True,
)

polarion_worker.patch_work_items(converter.converter_session)

Expand Down
31 changes: 0 additions & 31 deletions capella2polarion/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"""Tool for CLI work."""
from __future__ import annotations

import json
import logging
import pathlib
import typing
Expand All @@ -27,7 +26,6 @@ def __init__(
polarion_url: str,
polarion_pat: str,
polarion_delete_work_items: bool,
capella_diagram_cache_folder_path: pathlib.Path | None,
capella_model: capellambse.MelodyModel,
synchronize_config_io: typing.TextIO,
force_update: bool = False,
Expand All @@ -39,22 +37,9 @@ def __init__(
polarion_pat,
polarion_delete_work_items,
)
if capella_diagram_cache_folder_path is None:
raise ValueError("CapellaDiagramCacheFolderPath not filled")

self.capella_diagram_cache_folder_path = (
capella_diagram_cache_folder_path
)
self.capella_diagram_cache_index_file_path = (
self.capella_diagram_cache_folder_path / "index.json"
)
self.capella_diagram_cache_index_content: list[
dict[str, typing.Any]
] = []
self.capella_model: capellambse.MelodyModel = capella_model
self.synchronize_config_io: typing.TextIO = synchronize_config_io
self.synchronize_config_content: dict[str, typing.Any] = {}
self.synchronize_config_roles: dict[str, list[str]] | None = None
self.config = converter_config.ConverterConfig()
self.force_update = force_update

Expand Down Expand Up @@ -99,10 +84,6 @@ def _value(value):
string_value = self._none_save_value_string(string_value)
click.echo(f"{lighted_member_var}: '{string_value}'")

echo = ("NO", "YES")[
self.capella_diagram_cache_index_file_path.is_file()
]
click.echo(f"""Capella Diagram Cache Index-File exists: {echo}""")
echo = ("YES", "NO")[self.synchronize_config_io.closed]
click.echo(f"""Synchronize Config-IO is open: {echo}""")

Expand Down Expand Up @@ -133,15 +114,3 @@ def load_synchronize_config(self) -> None:
if not self.synchronize_config_io.readable():
raise RuntimeError("synchronize config io stream is not readable")
self.config.read_config_file(self.synchronize_config_io)

def load_capella_diagram_cache_index(self) -> None:
"""Load Capella Diagram Cache index file content."""
if not self.capella_diagram_cache_index_file_path.is_file():
raise ValueError(
"capella diagramm cache index.json file does not exist"
)

l_text_content = self.capella_diagram_cache_index_file_path.read_text(
encoding="utf8"
)
self.capella_diagram_cache_index_content = json.loads(l_text_content)
Loading
Loading