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

SwissDataScienceCenter / renku-python / 9903255773

12 Jul 2024 06:06AM UTC coverage: 77.595% (-8.5%) from 86.128%
9903255773

Pull #3730

github

RenkuBot
chore: release v2.9.4
Pull Request #3730: chore: release v2.9.4

1 of 1 new or added line in 1 file covered. (100.0%)

2624 existing lines in 126 files now uncovered.

23855 of 30743 relevant lines covered (77.59%)

3.23 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."""
7✔
17
import textwrap
7✔
18
from typing import Callable, Dict
7✔
19

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

23

24
def tabular(workflows, *, columns=None):
7✔
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):
7✔
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):
7✔
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):
7✔
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] = {
7✔
79
    "tabular": tabular,
80
    "json-ld": jsonld,
81
    "json": json,
82
}
83
"""Valid formatting options."""
7✔
84

85
WORKFLOW_COLUMNS = {
7✔
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 = {
7✔
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