Skip to content

Commit 24407e5

Browse files
fix(core): update template checksum when updating Dockerfile (#3351)
1 parent ac21c32 commit 24407e5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+640
-223
lines changed

renku/command/clone.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ def _project_clone(
6262
Tuple of cloned ``Repository`` and whether it's a Renku project or not.
6363
"""
6464
from renku.command.mergetool import setup_mergetool
65-
from renku.core.migration.migrate import is_renku_project
6665
from renku.core.util.git import clone_renku_repository
66+
from renku.core.util.metadata import is_renku_project
6767

6868
install_lfs = project_context.external_storage_requested
6969

renku/command/migrate.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -177,13 +177,9 @@ def check_project():
177177

178178

179179
def _check_project():
180-
from renku.core.migration.migrate import (
181-
is_docker_update_possible,
182-
is_migration_required,
183-
is_project_unsupported,
184-
is_renku_project,
185-
)
180+
from renku.core.migration.migrate import is_docker_update_possible, is_migration_required, is_project_unsupported
186181
from renku.core.template.usecase import check_for_template_update
182+
from renku.core.util.metadata import is_renku_project
187183

188184
if not is_renku_project():
189185
return NON_RENKU_REPOSITORY

renku/command/rollback.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,10 +149,10 @@ def _get_modifications_from_diff(diff):
149149
continue
150150

151151
# normal file
152-
if diff_index.change_type == "A":
152+
if diff_index.added:
153153
modifications["files"]["removed"].append(entry)
154154

155-
elif diff_index.change_type == "D":
155+
elif diff_index.deleted:
156156
modifications["files"]["restored"].append(entry)
157157
else:
158158
modifications["files"]["modified"].append(entry)

renku/command/schema/activity.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
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.command.schema.agent import PersonSchema, SoftwareAgentSchema
2323
from renku.command.schema.annotation import AnnotationSchema
@@ -124,6 +124,28 @@ class Meta:
124124
started_at_time = fields.DateTime(prov.startedAtTime, add_value_types=True)
125125
usages = Nested(prov.qualifiedUsage, UsageSchema, many=True)
126126

127+
@pre_dump(pass_many=True)
128+
def removes_ms(self, objs, many, **kwargs):
129+
"""Remove milliseconds from datetimes.
130+
131+
Note: since DateField uses `strftime` as format, which only supports timezone info without a colon
132+
e.g. `+0100` instead of `+01:00`, we have to deal with milliseconds manually instead of using a format string.
133+
"""
134+
135+
def _replace_times(obj):
136+
obj.unfreeze()
137+
obj.started_at_time = obj.started_at_time.replace(microsecond=0)
138+
obj.ended_at_time = obj.ended_at_time.replace(microsecond=0)
139+
obj.freeze()
140+
141+
if many:
142+
for obj in objs:
143+
_replace_times(obj)
144+
return objs
145+
146+
_replace_times(objs)
147+
return objs
148+
127149

128150
class WorkflowFileActivityCollectionSchema(JsonLDSchema):
129151
"""WorkflowFileActivityCollection schema."""

renku/command/schema/composite_plan.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
# limitations under the License.
1818
"""Represent a group of run templates."""
1919

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

2222
from renku.command.schema.agent import PersonSchema
2323
from renku.command.schema.calamus import JsonLDSchema, Nested, fields, prov, renku, schema
@@ -49,3 +49,27 @@ class Meta:
4949
project_id = fields.IRI(renku.hasPlan, reverse=True)
5050
plans = Nested(renku.hasSubprocess, [PlanSchema, "CompositePlanSchema"], many=True)
5151
links = Nested(renku.workflowLinks, [ParameterLinkSchema], many=True, load_default=None)
52+
53+
@pre_dump(pass_many=True)
54+
def removes_ms(self, objs, many, **kwargs):
55+
"""Remove milliseconds from datetimes.
56+
57+
Note: since DateField uses `strftime` as format, which only supports timezone info without a colon
58+
e.g. `+0100` instead of `+01:00`, we have to deal with milliseconds manually instead of using a format string.
59+
"""
60+
61+
def _replace_times(obj):
62+
obj.unfreeze()
63+
obj.date_created = obj.date_created.replace(microsecond=0)
64+
obj.date_modified = obj.date_modified.replace(microsecond=0)
65+
if obj.date_removed:
66+
obj.date_removed = obj.date_removed.replace(microsecond=0)
67+
obj.freeze()
68+
69+
if many:
70+
for obj in objs:
71+
_replace_times(obj)
72+
return objs
73+
74+
_replace_times(objs)
75+
return objs

renku/command/schema/dataset.py

Lines changed: 70 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
# limitations under the License.
1818
"""Datasets JSON-LD schemes."""
1919

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

2222
from renku.command.schema.agent import PersonSchema
2323
from renku.command.schema.annotation import AnnotationSchema
@@ -69,6 +69,27 @@ class Meta:
6969
id = fields.Id()
7070
name = fields.String(schema.name)
7171

72+
@pre_dump(pass_many=True)
73+
def removes_ms(self, objs, many, **kwargs):
74+
"""Remove milliseconds from datetimes.
75+
76+
Note: since DateField uses `strftime` as format, which only supports timezone info without a colon
77+
e.g. `+0100` instead of `+01:00`, we have to deal with milliseconds manually instead of using a format string.
78+
"""
79+
80+
def _replace_times(obj):
81+
obj.unfreeze()
82+
obj.date_created = obj.date_created.replace(microsecond=0)
83+
obj.freeze()
84+
85+
if many:
86+
for obj in objs:
87+
_replace_times(obj)
88+
return objs
89+
90+
_replace_times(objs)
91+
return objs
92+
7293

7394
class LanguageSchema(JsonLDSchema):
7495
"""Language schema."""
@@ -134,6 +155,27 @@ class Meta:
134155
is_external = fields.Boolean(renku.external, load_default=False)
135156
source = fields.String(renku.source, load_default=None)
136157

158+
@pre_dump(pass_many=True)
159+
def removes_ms(self, objs, many, **kwargs):
160+
"""Remove milliseconds from datetimes.
161+
162+
Note: since DateField uses `strftime` as format, which only supports timezone info without a colon
163+
e.g. `+0100` instead of `+01:00`, we have to deal with milliseconds manually instead of using a format string.
164+
"""
165+
166+
def _replace_times(obj):
167+
obj.date_added = obj.date_added.replace(microsecond=0)
168+
if obj.date_removed:
169+
obj.date_removed = obj.date_removed.replace(microsecond=0)
170+
171+
if many:
172+
for obj in objs:
173+
_replace_times(obj)
174+
return objs
175+
176+
_replace_times(objs)
177+
return objs
178+
137179

138180
class DatasetSchema(JsonLDSchema):
139181
"""Dataset schema."""
@@ -168,3 +210,30 @@ class Meta:
168210
same_as = Nested(schema.sameAs, UrlSchema, load_default=None)
169211
title = fields.String(schema.name)
170212
version = fields.String(schema.version, load_default=None)
213+
214+
@pre_dump(pass_many=True)
215+
def removes_ms(self, objs, many, **kwargs):
216+
"""Remove milliseconds from datetimes.
217+
218+
Note: since DateField uses `strftime` as format, which only supports timezone info without a colon
219+
e.g. `+0100` instead of `+01:00`, we have to deal with milliseconds manually instead of using a format string.
220+
"""
221+
222+
def _replace_times(obj):
223+
obj.unfreeze()
224+
if obj.date_created:
225+
obj.date_created = obj.date_created.replace(microsecond=0)
226+
if obj.date_removed:
227+
obj.date_removed = obj.date_removed.replace(microsecond=0)
228+
if obj.date_published:
229+
obj.date_published = obj.date_published.replace(microsecond=0)
230+
obj.date_modified = obj.date_modified.replace(microsecond=0)
231+
obj.freeze()
232+
233+
if many:
234+
for obj in objs:
235+
_replace_times(obj)
236+
return objs
237+
238+
_replace_times(objs)
239+
return objs

renku/command/schema/plan.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,27 @@ class Meta:
5454
parameters = Nested(renku.hasArguments, CommandParameterSchema, many=True, load_default=None)
5555
success_codes = fields.List(renku.successCodes, fields.Integer(), load_default=[0])
5656
annotations = Nested(oa.hasTarget, AnnotationSchema, reverse=True, many=True)
57+
58+
@marshmallow.pre_dump(pass_many=True)
59+
def removes_ms(self, objs, many, **kwargs):
60+
"""Remove milliseconds from datetimes.
61+
62+
Note: since DateField uses `strftime` as format, which only supports timezone info without a colon
63+
e.g. `+0100` instead of `+01:00`, we have to deal with milliseconds manually instead of using a format string.
64+
"""
65+
66+
def _replace_times(obj):
67+
obj.unfreeze()
68+
obj.date_created = obj.date_created.replace(microsecond=0)
69+
obj.date_modified = obj.date_modified.replace(microsecond=0)
70+
if obj.date_removed:
71+
obj.date_removed = obj.date_removed.replace(microsecond=0)
72+
obj.freeze()
73+
74+
if many:
75+
for obj in objs:
76+
_replace_times(obj)
77+
return objs
78+
79+
_replace_times(objs)
80+
return objs

renku/command/schema/project.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
# limitations under the License.
1818
"""Project JSON-LD schema."""
1919

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

2222
from renku.command.schema.agent import PersonSchema
2323
from renku.command.schema.annotation import AnnotationSchema
@@ -59,3 +59,22 @@ class Meta:
5959
)
6060
version = StringList(schema.schemaVersion, load_default="1")
6161
keywords = fields.List(schema.keywords, fields.String(), load_default=None)
62+
63+
@pre_dump(pass_many=True)
64+
def removes_ms(self, objs, many, **kwargs):
65+
"""Remove milliseconds from datetimes.
66+
67+
Note: since DateField uses `strftime` as format, which only supports timezone info without a colon
68+
e.g. `+0100` instead of `+01:00`, we have to deal with milliseconds manually instead of using a format string.
69+
"""
70+
71+
def _replace_times(obj):
72+
obj.date_created = obj.date_created.replace(microsecond=0)
73+
74+
if many:
75+
for obj in objs:
76+
_replace_times(obj)
77+
return objs
78+
79+
_replace_times(objs)
80+
return objs

renku/core/git.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,6 @@ def ensure_clean(ignore_std_streams=False):
207207
if dirty_paths - set(mapped_streams.values()):
208208
_clean_streams(repository, mapped_streams)
209209
raise errors.DirtyRepository(repository)
210-
elif repository.is_dirty():
210+
elif repository.is_dirty(untracked_files=False):
211211
_clean_streams(repository, mapped_streams)
212212
raise errors.DirtyRepository(repository)

renku/core/migration/m_0005__2_cwl.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def sort_cwl_commits(e1, e2):
107107

108108
repository.add(cwl_file, path)
109109

110-
if repository.is_dirty():
110+
if repository.is_dirty(untracked_files=False):
111111
commit_msg = "renku migrate: committing migrated workflow"
112112
committer = Actor(name=f"renku {__version__}", email=version_url)
113113
repository.commit(commit_msg + project_context.transaction_id, committer=committer, no_verify=True)

0 commit comments

Comments
 (0)