1414# See the License for the specific language governing permissions and
1515# limitations under the License.
1616"""Checks needed to determine integrity of workflows."""
17+
1718from datetime import timedelta
1819from typing import List , Optional , Tuple , cast
1920
@@ -145,14 +146,17 @@ def check_plan_id(fix, plan_gateway: IPlanGateway, **_) -> Tuple[bool, bool, Opt
145146 plans : List [AbstractPlan ] = plan_gateway .get_all_plans ()
146147
147148 to_be_processed = []
149+ to_be_processed_derived = []
148150 for plan in plans :
149151 if isinstance (plan .id , str ) and plan .id .startswith ("/plans//plans" ):
150152 to_be_processed .append (plan )
153+ if isinstance (plan .derived_from , str ) and plan .derived_from .startswith ("/plans//plans" ):
154+ to_be_processed_derived .append (plan )
151155
152- if not to_be_processed :
156+ if not to_be_processed and not to_be_processed_derived :
153157 return True , False , None
154158 if not fix :
155- ids = [plan .id for plan in to_be_processed ]
159+ ids = [plan .id for plan in to_be_processed + to_be_processed_derived ]
156160 message = (
157161 WARNING
158162 + "The following workflows have incorrect IDs (use 'renku doctor --fix' to fix them):\n \t "
@@ -163,7 +167,17 @@ def check_plan_id(fix, plan_gateway: IPlanGateway, **_) -> Tuple[bool, bool, Opt
163167 for plan in to_be_processed :
164168 plan .unfreeze ()
165169 plan .id = plan .id .replace ("//plans/" , "/" )
170+ plan .reassign_oid ()
171+ plan ._p_changed = True
166172 plan .freeze ()
173+
174+ for plan in to_be_processed_derived :
175+ if plan .derived_from is not None :
176+ plan .unfreeze ()
177+ plan .derived_from = plan .derived_from .replace ("//plans/" , "/" )
178+ plan ._p_changed = True
179+ plan .freeze ()
180+
167181 project_context .database .commit ()
168182 communication .info ("Workflow IDs were fixed" )
169183
0 commit comments