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

SwissDataScienceCenter / renku-python / 9058668052

13 May 2024 07:05AM UTC coverage: 77.713% (-8.4%) from 86.115%
9058668052

Pull #3727

github

web-flow
Merge 128d38387 into 050ed61bf
Pull Request #3727: fix: don't fail session launch when gitlab couldn't be reached

15 of 29 new or added lines in 3 files covered. (51.72%)

2594 existing lines in 125 files now uncovered.

23893 of 30745 relevant lines covered (77.71%)

3.2 hits per line

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

36.0
/renku/command/format/session.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 sessions."""
7✔
17

18
from typing import List, Optional
7✔
19

20
from renku.command.format.tabulate import tabulate
7✔
21
from renku.domain_model.session import Session
7✔
22

23

24
def tabular(sessions: List[Session], *, columns: Optional[str] = None):
7✔
25
    """Format sessions with a tabular output."""
UNCOV
26
    if not columns:
×
UNCOV
27
        columns = "id,start_time,status,provider,url"
×
28

UNCOV
29
        if any(s.ssh_enabled for s in sessions):
×
30
            columns += ",ssh"
×
31

UNCOV
32
    return tabulate(collection=sessions, columns=columns, columns_mapping=SESSION_COLUMNS)
×
33

34

35
def log(sessions: List[Session], *, columns: Optional[str] = None):
7✔
36
    """Format sessions in a log like output."""
UNCOV
37
    from renku.ui.cli.utils.terminal import style_header, style_key
×
38

UNCOV
39
    output = []
×
40

UNCOV
41
    for session in sessions:
×
UNCOV
42
        output.append(style_header(f"Session {session.id} ({session.status}, {session.provider})"))
×
UNCOV
43
        output.append(style_key("Started: ") + session.start_time.isoformat())
×
UNCOV
44
        output.append(style_key("Url: ") + session.url)
×
UNCOV
45
        output.append(style_key("Commit: ") + session.commit)
×
UNCOV
46
        output.append(style_key("Branch: ") + session.branch)
×
UNCOV
47
        output.append(style_key("SSH enabled: ") + ("yes" if session.ssh_enabled else "no"))
×
UNCOV
48
        output.append("")
×
UNCOV
49
    return "\n".join(output)
×
50

51

52
SESSION_FORMATS = {"tabular": tabular, "log": log}
7✔
53
"""Valid formatting options."""
7✔
54

55
SESSION_COLUMNS = {
7✔
56
    "id": ("id", "id"),
57
    "status": ("status", "status"),
58
    "url": ("url", "url"),
59
    "ssh": ("ssh_enabled", "SSH enabled"),
60
    "start_time": ("start_time", "start_time"),
61
    "commit": ("commit", "commit"),
62
    "branch": ("branch", "branch"),
63
    "provider": ("provider", "provider"),
64
}
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