Skip to content

Commit 1aecd9f

Browse files
authored
chore: release v1.1.1 (#2748)
1 parent 639ba2c commit 1aecd9f

File tree

15 files changed

+220
-44
lines changed

15 files changed

+220
-44
lines changed

CHANGES.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,17 @@
1818
Changes
1919
=======
2020

21+
`1.1.1 <https://github.com/SwissDataScienceCenter/renku-python/compare/v1.1.0...v1.1.1>`__ (2022-03-10)
22+
-------------------------------------------------------------------------------------------------------
23+
24+
This is a hotfix release fixing an issue with id generation for activities.
25+
26+
Bug Fixes
27+
~~~~~~~~~
28+
29+
- **core:** Add doctor fix and on-the-fly migration for wrong activity ids
30+
(`#2747 <https://github.com/SwissDataScienceCenter/renku-python/issues/2747>`__)
31+
2132
`1.1.0 <https://github.com/SwissDataScienceCenter/renku-python/compare/v1.0.6...v1.1.0>`__ (2022-03-04)
2233
-------------------------------------------------------------------------------------------------------
2334

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ DOCKER_PREFIX:=${DOCKER_REGISTRY}$(DOCKER_REPOSITORY)
2222
GIT_MASTER_HEAD_SHA:=$(shell git rev-parse --short --verify HEAD)
2323

2424
TEMPLATE_URL:=https://github.com/SwissDataScienceCenter/renku-project-template
25-
TEMPLATE_REFERENCE:=0.2.1
25+
TEMPLATE_REFERENCE:=0.3.0
2626
TEMPLATE_DIR:=renku/templates/
2727

2828
.PHONY: service cli docker-tag docker-push docker-login

docs/spelling_wordlist.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ gitlabClientSecret
8181
GraphQL
8282
Homebrew
8383
hostname
84+
hotfix
8485
https
8586
hyperkit
8687
hypervisor

helm-chart/renku-core/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ appVersion: "1.0"
33
description: A Helm chart for Kubernetes
44
name: renku-core
55
icon: https://avatars0.githubusercontent.com/u/53332360?s=400&u=a4311d22842343604ef61a8c8a1e5793209a67e9&v=4
6-
version: 1.1.0
6+
version: 1.1.1

helm-chart/renku-core/values.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ global:
1616
tag: '0.0.1'
1717
customCAs: []
1818
# - secret:
19-
19+
2020
## Redis configuration. This is where renku-core expects to find
2121
## a functioning redis instance and credentials to connect to it.
2222
redis:
@@ -27,7 +27,7 @@ global:
2727
coreService: "1"
2828
host: renku-redis
2929
port: 26379
30-
clientLabel:
30+
clientLabel:
3131
renku-redis-host: "true"
3232
existingSecret: redis-secret
3333
existingSecretPasswordKey: redis-password
@@ -109,7 +109,7 @@ versions:
109109
fullnameOverride: ""
110110
image:
111111
repository: renku/renku-core
112-
tag: "v1.0.6"
112+
tag: "v1.1.1"
113113
pullPolicy: IfNotPresent
114114
v8:
115115
name: v8

poetry.lock

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

renku/core/commands/checks/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
# limitations under the License.
1818
"""Define repository checks for :program:`renku doctor`."""
1919

20+
from .activities import check_migrated_activity_ids
2021
from .datasets import check_dataset_old_metadata_location, check_invalid_datasets_derivation, check_missing_files
2122
from .external import check_missing_external_files
2223
from .githooks import check_git_hooks_installed
@@ -33,6 +34,7 @@
3334
"check_git_hooks_installed",
3435
"check_invalid_datasets_derivation",
3536
"check_lfs_info",
37+
"check_migrated_activity_ids",
3638
"check_migration",
3739
"check_missing_external_files",
3840
"check_missing_files",
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# -*- coding: utf-8 -*-
2+
#
3+
# Copyright 2020 - Swiss Data Science Center (SDSC)
4+
# A partnership between École Polytechnique Fédérale de Lausanne (EPFL) and
5+
# Eidgenössische Technische Hochschule Zürich (ETHZ).
6+
#
7+
# Licensed under the Apache License, Version 2.0 (the "License");
8+
# you may not use this file except in compliance with the License.
9+
# You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS,
15+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
# See the License for the specific language governing permissions and
17+
# limitations under the License.
18+
"""Checks needed to determine integrity of datasets."""
19+
20+
from itertools import chain
21+
22+
import click
23+
24+
from renku.core.commands.echo import WARNING
25+
from renku.core.management.command_builder import inject
26+
from renku.core.management.interface.activity_gateway import IActivityGateway
27+
from renku.core.management.interface.database_dispatcher import IDatabaseDispatcher
28+
from renku.core.utils import communication
29+
30+
31+
@inject.autoparams()
32+
def check_migrated_activity_ids(
33+
client, fix, activity_gateway: IActivityGateway, database_dispatcher: IDatabaseDispatcher
34+
):
35+
"""Check that activity ids were correctly migrated in the past."""
36+
activities = activity_gateway.get_all_activities()
37+
38+
wrong_activities = [a for a in activities if not a.id.startswith("/activities/")]
39+
40+
if fix:
41+
current_database = database_dispatcher.current_database
42+
for activity in wrong_activities:
43+
communication.info(f"Fixing activity '{activity.id}'")
44+
45+
old_id = activity.id
46+
47+
# NOTE: Remove activity relations
48+
tok = current_database["activity-catalog"].tokenizeQuery
49+
relations = chain(
50+
list(current_database["activity-catalog"].findRelationChains(tok(downstream=activity))),
51+
list(current_database["activity-catalog"].findRelationChains(tok(upstream=activity))),
52+
)
53+
for rel_collection in relations:
54+
for r in list(rel_collection):
55+
current_database["activity-catalog"].unindex(r)
56+
57+
current_database["activities"].pop(old_id)
58+
59+
# NOTE: Modify id on activity and children
60+
activity.unfreeze()
61+
activity.id = f"/activities/{activity.id}"
62+
activity._p_oid = current_database.hash_id(activity.id)
63+
activity.freeze()
64+
65+
for usage in activity.usages:
66+
current_database["activities-by-usage"][usage.entity.path] = [
67+
a for a in current_database["activities-by-usage"][usage.entity.path] if a != activity
68+
]
69+
object.__setattr__(usage, "id", f"/activities/{usage.id}")
70+
71+
for generation in activity.generations:
72+
current_database["activities-by-generation"][generation.entity.path] = [
73+
a for a in current_database["activities-by-generation"][generation.entity.path] if a != activity
74+
]
75+
object.__setattr__(generation, "id", f"/activities/{generation.id}")
76+
77+
for parameter in activity.parameters:
78+
object.__setattr__(parameter, "id", f"/activities/{parameter.id}")
79+
80+
activity.association.id = f"/activities/{activity.association.id}"
81+
82+
activity_gateway.add(activity)
83+
84+
wrong_activities = []
85+
86+
if not wrong_activities:
87+
return True, None
88+
89+
problems = (
90+
WARNING
91+
+ "There are invalid activity ids in the project (use 'renku doctor --fix' to fix them):"
92+
+ "\n\n\t"
93+
+ "\n\t".join(click.style(a.id, fg="yellow") for a in wrong_activities)
94+
+ "\n"
95+
)
96+
97+
return False, problems

renku/core/commands/schema/activity.py

Lines changed: 67 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,42 @@
1717
# limitations under the License.
1818
"""Activity JSON-LD schema."""
1919

20-
from marshmallow import EXCLUDE
20+
from marshmallow import EXCLUDE, pre_dump
2121

2222
from renku.core.commands.schema.agent import PersonSchema, SoftwareAgentSchema
2323
from renku.core.commands.schema.annotation import AnnotationSchema
24-
from renku.core.commands.schema.calamus import JsonLDSchema, Nested, fields, oa, prov, renku
24+
from renku.core.commands.schema.calamus import JsonLDSchema, Nested, fields, oa, prov, renku, schema
2525
from renku.core.commands.schema.entity import CollectionSchema, EntitySchema
26-
from renku.core.commands.schema.parameter import ParameterValueSchema
2726
from renku.core.commands.schema.plan import PlanSchema
2827
from renku.core.models.provenance.activity import Activity, Association, Generation, Usage
28+
from renku.core.models.provenance.parameter import ParameterValue
2929

3030
NON_EXISTING_ENTITY_CHECKSUM = "0" * 40
3131

3232

33+
class _ObjectWrapper:
34+
"""Object wrapper that allows temporarily overriding fields of immutable objects."""
35+
36+
def __init__(self, wrapped, **override):
37+
self.__wrapped = wrapped
38+
self.__override = override
39+
40+
def __getattr__(self, name):
41+
if name in self.__override:
42+
return self.__override[name]
43+
44+
return getattr(self.__wrapped, name)
45+
46+
47+
def _fix_id(obj):
48+
"""Fix ids under an activity that were wrong due to a bug."""
49+
50+
if not obj.id.startswith("/activities/"):
51+
obj = _ObjectWrapper(obj, id=f"/activities/{obj.id}")
52+
53+
return obj
54+
55+
3356
class AssociationSchema(JsonLDSchema):
3457
"""Association schema."""
3558

@@ -44,6 +67,11 @@ class Meta:
4467
id = fields.Id()
4568
plan = Nested(prov.hadPlan, PlanSchema)
4669

70+
@pre_dump
71+
def _pre_dump(self, obj, **kwargs):
72+
"""Pre-dump hook."""
73+
return _fix_id(obj)
74+
4775

4876
class UsageSchema(JsonLDSchema):
4977
"""Usage schema."""
@@ -59,6 +87,11 @@ class Meta:
5987
# TODO: DatasetSchema, DatasetFileSchema
6088
entity = Nested(prov.entity, [EntitySchema, CollectionSchema])
6189

90+
@pre_dump
91+
def _pre_dump(self, obj, **kwargs):
92+
"""Pre-dump hook."""
93+
return _fix_id(obj)
94+
6295

6396
class GenerationSchema(JsonLDSchema):
6497
"""Generation schema."""
@@ -74,6 +107,32 @@ class Meta:
74107
# TODO: DatasetSchema, DatasetFileSchema
75108
entity = Nested(prov.qualifiedGeneration, [EntitySchema, CollectionSchema], reverse=True)
76109

110+
@pre_dump
111+
def _pre_dump(self, obj, **kwargs):
112+
"""Pre-dump hook."""
113+
return _fix_id(obj)
114+
115+
116+
class ParameterValueSchema(JsonLDSchema):
117+
"""ParameterValue schema."""
118+
119+
class Meta:
120+
"""Meta class."""
121+
122+
rdf_type = [renku.ParameterValue, schema.PropertyValue]
123+
model = ParameterValue
124+
unknown = EXCLUDE
125+
126+
id = fields.Id()
127+
128+
parameter = fields.IRI(schema.valueReference, attribute="parameter_id")
129+
value = fields.Raw(schema.value)
130+
131+
@pre_dump
132+
def _pre_dump(self, obj, **kwargs):
133+
"""Pre-dump hook."""
134+
return _fix_id(obj)
135+
77136

78137
class ActivitySchema(JsonLDSchema):
79138
"""Activity schema."""
@@ -102,3 +161,8 @@ class Meta:
102161
project_id = fields.IRI(renku.hasActivity, reverse=True)
103162
started_at_time = fields.DateTime(prov.startedAtTime, add_value_types=True)
104163
usages = Nested(prov.qualifiedUsage, UsageSchema, many=True)
164+
165+
@pre_dump
166+
def _pre_dump(self, obj, **kwargs):
167+
"""Pre-dump hook."""
168+
return _fix_id(obj)

renku/core/commands/schema/parameter.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
from marshmallow import EXCLUDE
2121

2222
from renku.core.commands.schema.calamus import JsonLDSchema, Nested, fields, prov, renku, schema
23-
from renku.core.models.provenance.parameter import ParameterValue
2423
from renku.core.models.workflow.parameter import (
2524
CommandInput,
2625
CommandOutput,
@@ -32,22 +31,6 @@
3231
)
3332

3433

35-
class ParameterValueSchema(JsonLDSchema):
36-
"""ParameterValue schema."""
37-
38-
class Meta:
39-
"""Meta class."""
40-
41-
rdf_type = [renku.ParameterValue, schema.PropertyValue]
42-
model = ParameterValue
43-
unknown = EXCLUDE
44-
45-
id = fields.Id()
46-
47-
parameter = fields.IRI(schema.valueReference, attribute="parameter_id")
48-
value = fields.Raw(schema.value)
49-
50-
5134
class MappedIOStreamSchema(JsonLDSchema):
5235
"""MappedIOStream schema."""
5336

0 commit comments

Comments
 (0)