From 7fe8dc0adba7f5326d9cb022373e590968404776 Mon Sep 17 00:00:00 2001 From: "H. Vetinari" Date: Fri, 22 Aug 2025 14:07:53 +1100 Subject: [PATCH 1/2] switch migration application to be determined by (base) filename, not migrator_ts --- conda_smithy/configure_feedstock.py | 12 +++++----- ...mps-to-determine-migration-application.rst | 23 +++++++++++++++++++ 2 files changed, 29 insertions(+), 6 deletions(-) create mode 100644 news/2368-don't-use-timestamps-to-determine-migration-application.rst diff --git a/conda_smithy/configure_feedstock.py b/conda_smithy/configure_feedstock.py index 07e5aa168..31d9e4641 100644 --- a/conda_smithy/configure_feedstock.py +++ b/conda_smithy/configure_feedstock.py @@ -2694,7 +2694,7 @@ def make_jinja_env(feedstock_directory): def get_migrations_in_dir(migrations_root): """ Given a directory, return the migrations as a mapping - from the (filename, timestamp) to (full_path, migration_number, use_local) + from the filename to a tuple of (full_path, migration_number, timestamp, use_local) """ res = {} for full_path in glob.glob(os.path.join(migrations_root, "*.yaml")): @@ -2711,7 +2711,7 @@ def get_migrations_in_dir(migrations_root): == "true" ) fn = os.path.basename(full_path) - res[(fn, ts)] = (full_path, migration_number, use_local) + res[fn] = (full_path, migration_number, ts, use_local) return res @@ -2747,21 +2747,21 @@ def set_migration_fns(forge_dir, forge_config): migrations_in_feedstock = get_migrations_in_dir(migrations_root) if not os.path.exists(cfp_migrations_dir): - migration_fns = [fp for fp, _, _ in migrations_in_feedstock.values()] + migration_fns = [fp for fp, _, _, _ in migrations_in_feedstock.values()] forge_config["migration_fns"] = migration_fns return migrations_in_cfp = get_migrations_in_dir(cfp_migrations_dir) result = [] - for (fn, ts), (full_path, num, use_local) in migrations_in_feedstock.items(): + for fn, (full_path, num, ts, use_local) in migrations_in_feedstock.items(): if use_local or not isinstance(ts, (int, str, float)): # This file has a setting to use the file in the feedstock # or doesn't have a timestamp. Use it as it is. result.append(full_path) - elif (fn, ts) in migrations_in_cfp: + elif fn in migrations_in_cfp: # Use the one from cfp if migration_numbers match - new_full_path, new_num, _ = migrations_in_cfp[(fn, ts)] + new_full_path, new_num, _, _ = migrations_in_cfp[fn] if num == new_num: logger.info( "%s from feedstock is ignored and upstream version is used", diff --git a/news/2368-don't-use-timestamps-to-determine-migration-application.rst b/news/2368-don't-use-timestamps-to-determine-migration-application.rst new file mode 100644 index 000000000..218d517cd --- /dev/null +++ b/news/2368-don't-use-timestamps-to-determine-migration-application.rst @@ -0,0 +1,23 @@ +**Added:** + +* + +**Changed:** + +* Avoid using migration timestamps to determine whether migrations should be applied. The logic for ``use_local`` and ``migration_number`` remains unchanged, but migrations are now uniformly applied based on the name of the migrator file, and timestamps are only used to order the application of migrators (#2368). + +**Deprecated:** + +* + +**Removed:** + +* + +**Fixed:** + +* + +**Security:** + +* From 8ad787fe42e9e290ee0482209fe2359c725335fa Mon Sep 17 00:00:00 2001 From: "H. Vetinari" Date: Fri, 22 Aug 2025 23:34:49 +1100 Subject: [PATCH 2/2] remove timestamp from migration logic and get_migrations_in_dir --- conda_smithy/configure_feedstock.py | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/conda_smithy/configure_feedstock.py b/conda_smithy/configure_feedstock.py index 31d9e4641..69e17e84e 100644 --- a/conda_smithy/configure_feedstock.py +++ b/conda_smithy/configure_feedstock.py @@ -2694,15 +2694,13 @@ def make_jinja_env(feedstock_directory): def get_migrations_in_dir(migrations_root): """ Given a directory, return the migrations as a mapping - from the filename to a tuple of (full_path, migration_number, timestamp, use_local) + from the filename to a tuple of (full_path, migration_number, use_local) """ res = {} for full_path in glob.glob(os.path.join(migrations_root, "*.yaml")): with open(full_path, encoding="utf-8") as f: contents = f.read() migration_yaml = yaml.load(contents, Loader=yaml.loader.BaseLoader) or {} - # Use a object as timestamp to not delete it - ts = migration_yaml.get("migrator_ts", object()) migration_number = migration_yaml.get("__migrator", {}).get( "migration_number", 1 ) @@ -2711,7 +2709,7 @@ def get_migrations_in_dir(migrations_root): == "true" ) fn = os.path.basename(full_path) - res[fn] = (full_path, migration_number, ts, use_local) + res[fn] = (full_path, migration_number, use_local) return res @@ -2747,21 +2745,19 @@ def set_migration_fns(forge_dir, forge_config): migrations_in_feedstock = get_migrations_in_dir(migrations_root) if not os.path.exists(cfp_migrations_dir): - migration_fns = [fp for fp, _, _, _ in migrations_in_feedstock.values()] + migration_fns = [fp for fp, _, _ in migrations_in_feedstock.values()] forge_config["migration_fns"] = migration_fns return migrations_in_cfp = get_migrations_in_dir(cfp_migrations_dir) result = [] - for fn, (full_path, num, ts, use_local) in migrations_in_feedstock.items(): - if use_local or not isinstance(ts, (int, str, float)): - # This file has a setting to use the file in the feedstock - # or doesn't have a timestamp. Use it as it is. + for fn, (full_path, num, use_local) in migrations_in_feedstock.items(): + if use_local: result.append(full_path) elif fn in migrations_in_cfp: # Use the one from cfp if migration_numbers match - new_full_path, new_num, _, _ = migrations_in_cfp[fn] + new_full_path, new_num, _ = migrations_in_cfp[fn] if num == new_num: logger.info( "%s from feedstock is ignored and upstream version is used", @@ -2773,9 +2769,8 @@ def set_migration_fns(forge_dir, forge_config): else: # Delete this as this migration is over. logger.info( - "%s with timestamp %s does not exist in global pinning (anymore), removing it.", + "%s does not exist in global pinning (anymore), removing it.", fn, - ts, ) logger.info( "If it should be applied nevertheless, check that migrator_ts/migration_number match the ones in "