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

SwissDataScienceCenter / renku-python / 5948296099

23 Aug 2023 07:23AM UTC coverage: 85.801% (+0.04%) from 85.766%
5948296099

Pull #3601

github-actions

olevski
chore: run poetry lock
Pull Request #3601: hotfix: v2.6.1

40 of 48 new or added lines in 10 files covered. (83.33%)

285 existing lines in 25 files now uncovered.

25875 of 30157 relevant lines covered (85.8%)

4.9 hits per line

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

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

20
from renku.ui.service.cache.base import BaseCache
5✔
21
from renku.ui.service.cache.models.project import Project
5✔
22
from renku.ui.service.cache.models.user import User
5✔
23
from renku.ui.service.cache.serializers.project import ProjectSchema
5✔
24
from renku.ui.service.errors import IntermittentProjectIdError
5✔
25

26

27
class ProjectManagementCache(BaseCache):
5✔
28
    """Project management cache."""
29

30
    project_schema = ProjectSchema()
5✔
31

32
    def make_project(self, user, project_data, persist=True):
5✔
33
        """Store user project metadata."""
34
        project_data.update({"user_id": user.user_id})
3✔
35

36
        project_obj = self.project_schema.load(project_data, unknown=EXCLUDE)
3✔
37

38
        if persist:
3✔
39
            project_obj.save()
2✔
40

41
        return project_obj
3✔
42

43
    @staticmethod
5✔
44
    def get_project(user, project_id):
5✔
45
        """Get user cached project."""
46
        try:
2✔
47
            record = Project.get((Project.project_id == project_id) & (Project.user_id == user.user_id))
2✔
48
        except ValueError as e:
1✔
49
            raise IntermittentProjectIdError(e)
1✔
50

51
        if not record.abs_path.exists():
2✔
UNCOV
52
            record.delete()
×
UNCOV
53
            raise IntermittentProjectIdError()
×
54

55
        return record
2✔
56

57
    @staticmethod
5✔
58
    def get_projects(user):
5✔
59
        """Get all user cache projects."""
60
        return Project.query(Project.user_id == user.user_id)
3✔
61

62
    @staticmethod
5✔
63
    def invalidate_project(user, project_id):
5✔
64
        """Remove user project record."""
65
        project_obj = ProjectManagementCache.get_project(user, project_id)
1✔
66

67
        if project_obj:
1✔
68
            project_obj.purge()
1✔
69

70
        return project_obj
1✔
71

72
    def user_projects(self):
5✔
73
        """Iterate through all cached projects."""
74
        for user in User.all():
3✔
75
            yield user, self.get_projects(user)
3✔
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