• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

SwissDataScienceCenter / renku-python / 5819047457

pending completion
5819047457

push

github-actions

web-flow
Merge pull request #3580 from SwissDataScienceCenter/release/v2.7.0

chore: release v2.7.0

224 of 312 new or added lines in 29 files covered. (71.79%)

2739 existing lines in 132 files now uncovered.

22657 of 29584 relevant lines covered (76.59%)

7.64 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

50.0
/renku/command/format/workflow.py
1
# Copyright Swiss Data Science Center (SDSC). A partnership between
2
# École Polytechnique Fédérale de Lausanne (EPFL) and
3
# Eidgenössische Technische Hochschule Zürich (ETHZ).
4
#
5
# Licensed under the Apache License, Version 2.0 (the "License");
6
# you may not use this file except in compliance with the License.
7
# You may obtain a copy of the License at
8
#
9
#     http://www.apache.org/licenses/LICENSE-2.0
10
#
11
# Unless required by applicable law or agreed to in writing, software
12
# distributed under the License is distributed on an "AS IS" BASIS,
13
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
# See the License for the specific language governing permissions and
15
# limitations under the License.
16
"""Serializers for workflows."""
18✔
17
import textwrap
18✔
18
from typing import Callable, Dict
18✔
19

20
from renku.command.format.json import dumps
18✔
21
from renku.command.format.tabulate import tabulate
18✔
22

23

24
def tabular(workflows, *, columns=None):
18✔
25
    """Format workflows with a tabular output.
26

27
    Args:
28
        workflows: Workflows to format.
29
        columns: Columns to show (Default value = None).
30

31
    Returns:
32
        Workflows in tabular format.
33
    """
UNCOV
34
    if not columns:
×
35
        columns = "id,name,keywords"
×
36

UNCOV
37
    _create_workflow_short_description(workflows)
×
38

UNCOV
39
    return tabulate(collection=workflows, columns=columns, columns_mapping=WORKFLOW_COLUMNS)
×
40

41

42
def _create_workflow_short_description(workflows):
18✔
UNCOV
43
    for workflow in workflows:
×
UNCOV
44
        lines = textwrap.wrap(workflow.description, width=64, max_lines=5) if workflow.description else []
×
UNCOV
45
        workflow.short_description = "\n".join(lines)
×
46

47

48
def jsonld(workflows, **kwargs):
18✔
49
    """Format workflow as JSON-LD.
50

51
    Args:
52
        workflows: Workflows to convert.
53

54
    Returns:
55
        JSON-LD string of workflows.
56
    """
57
    from renku.command.schema.plan import PlanSchema
×
58

59
    data = [PlanSchema().dump(workflow) for workflow in workflows]
×
60
    return dumps(data, indent=2)
×
61

62

63
def json(workflows, **kwargs):
18✔
64
    """Format workflow as JSON.
65

66
    Args:
67
        workflows: Workflows to convert.
68

69
    Returns:
70
        String of JSON data.
71
    """
UNCOV
72
    from renku.domain_model.workflow.plan import PlanDetailsJson
×
73

UNCOV
74
    data = [PlanDetailsJson().dump(workflow) for workflow in workflows]
×
UNCOV
75
    return dumps(data, indent=2)
×
76

77

78
WORKFLOW_FORMATS: Dict[str, Callable] = {
18✔
79
    "tabular": tabular,
80
    "json-ld": jsonld,
81
    "json": json,
82
}
83
"""Valid formatting options."""
9✔
84

85
WORKFLOW_COLUMNS = {
18✔
86
    "id": ("id", "id"),
87
    "name": ("name", None),
88
    "keywords": ("keywords_csv", "keywords"),
89
    "description": ("short_description", "description"),
90
    "command": ("full_command", "command"),
91
}
92

93
WORKFLOW_VISUALIZE_FORMATS = {
18✔
94
    "console": "console",
95
    "dot": "dot",
96
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc