Skip to content

Advance deprecation cycle for Zenodo functions#285

Merged
sbfnk merged 8 commits intomainfrom
advance-deprecation
Feb 9, 2026
Merged

Advance deprecation cycle for Zenodo functions#285
sbfnk merged 8 commits intomainfrom
advance-deprecation

Conversation

@sbfnk
Copy link
Collaborator

@sbfnk sbfnk commented Feb 4, 2026

Summary

  • Advance deprecation from deprecate_soft to deprecate_warn for get_survey(), download_survey(), list_surveys(), get_citation(), and survey_countries()
  • Consolidate all deprecated functions into R/deprecated.R
  • Remove tests that hit Zenodo (too costly for deprecated functionality)
  • Update tests to use lifecycle::expect_deprecated()

This PR closes #269.

Summary by CodeRabbit

  • Deprecation Notices

    • get_survey(), download_survey(), list_surveys(), get_citation(), and survey_countries() now always emit deprecation warnings and point to the contactsurveys package.
  • Removed / Deprecated APIs

    • Legacy implementations were removed and replaced with deprecated wrappers exposing the same call sites but issuing warnings.
  • Documentation

    • Help headers updated to reference the consolidated deprecated implementations.
  • Tests

    • Tests updated to assert deprecation expectations instead of snapshot warnings.

sbfnk and others added 2 commits February 4, 2026 21:18
Co-authored-by: sbfnk-bot <242615673+sbfnk-bot@users.noreply.github.com>
Co-authored-by: sbfnk-bot <242615673+sbfnk-bot@users.noreply.github.com>
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 4, 2026

Important

Review skipped

This PR was authored by the user configured for CodeRabbit reviews. By default, CodeRabbit skips reviewing PRs authored by this user. It's recommended to use a dedicated user account to post CodeRabbit review feedback.

To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Consolidates legacy Zenodo survey functionality into a new R/deprecated.R module: original implementations removed, deprecated wrappers added that emit lifecycle warnings and forward users to the contactsurveys package; related docs, tests, and NEWS entries updated.

Changes

Cohort / File(s) Summary
Deprecated wrappers
R/deprecated.R
Adds consolidated deprecated wrappers for get_survey, download_survey, list_surveys, survey_countries, and get_citation; each emits lifecycle deprecation warnings and delegates to contactsurveys or internal helpers; includes helper utilities and memoisation.
Removed originals
R/cite.R, R/download_survey.R, R/get_survey.R, R/lists.R
Removes prior full implementations and helpers for survey download/retrieval/listing/citation/country utilities; behavior replaced by the new deprecated wrappers.
Documentation updates
man/get_survey.Rd, man/download_survey.Rd, man/get_citation.Rd, man/list_surveys.Rd, man/survey_countries.Rd, man/is_doi.Rd, man/dot-get_survey.Rd
Roxygen source references updated to R/deprecated.R; some argument descriptions shortened or marked unused; no API signature changes.
News
NEWS.md
Adds development note that get_survey(), download_survey(), list_surveys(), get_citation(), and survey_countries() now emit unconditional warnings and directs users to contactsurveys.
Tests & snapshots
tests/testthat/*, tests/testthat/_snaps/*
Removes or updates Zenodo-dependent tests and snapshots; snapshot-based deprecation checks replaced with lifecycle::expect_deprecated() in places; long-running/download tests and related snapshots removed.
Test adjustments
tests/testthat/test-matrix.r, tests/testthat/test-countries.r, tests/testthat/test-surveys.r, tests/testthat/test-download-survey.R, tests/testthat/test-load-survey.R
Silences lifecycle verbosity in tests, converts deprecation assertions to lifecycle expectations, and drops tests that relied on external Zenodo interactions or long downloads.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Poem

🐰 I nibbled through code, then gave a small hop,
Five functions now point where new seedlings crop.
"Use contactsurveys," I softly declare,
I left gentle warnings and tidy-up care.
A twitch of my nose — migrations done with flair.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Advance deprecation cycle for Zenodo functions' accurately captures the primary change: transitioning soft-deprecated functions to unconditional warnings.
Linked Issues check ✅ Passed The PR implements all coding requirements from issue #269: functions emit unconditional warnings, deprecated wrappers consolidate in R/deprecated.R, tests using lifecycle::expect_deprecated replace snapshot checks, and Zenodo-dependent tests are removed.
Out of Scope Changes check ✅ Passed All changes align with advancing the deprecation cycle and removing Zenodo test dependencies. Documentation updates and test refactoring are necessary supporting changes within scope.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Fix all issues with AI agents
In `@R/deprecated.R`:
- Around line 356-357: survey_countries() currently triggers two deprecation
warnings because it emits one itself and then calls get_survey() which emits
another; to fix this, suppress the inner deprecation warning when calling
get_survey() from survey_countries by wrapping the call (the invocation of
get_survey(...) inside survey_countries) with a warning-suppression utility
(e.g., suppressWarnings or a targeted withCallingHandlers that filters only the
deprecation condition) so that only survey_countries()'s deprecation warning is
shown while preserving other non-deprecation warnings.
- Line 389: get_citation() currently triggers two deprecation warnings because
it emits its own warning then calls get_survey() which emits another; update
get_citation() to suppress the inner deprecation from get_survey by wrapping the
call to get_survey(x) with a warning-suppression mechanism (e.g.,
suppressWarnings or an equivalent that only silences the deprecation) so only
the single intended deprecation from get_citation() is shown; ensure you still
return the survey value from get_survey() and only suppress the warning emitted
by get_survey().
- Around line 65-78: The documentation for get_survey claims options for clean()
are inherited but .get_survey never calls clean; update .get_survey to invoke
clean on the survey before returning. Specifically, after constructing
new_survey in .get_survey (cases using copy(survey) or
load_survey(download_survey(...))), call clean(new_survey, ...) so the passed
... options are applied, then return the cleaned object; keep existing behavior
for error handling via cli::cli_abort and ensure you reference the existing
functions .get_survey, clean, download_survey, and load_survey when making the
change.

Co-authored-by: sbfnk-bot <242615673+sbfnk-bot@users.noreply.github.com>
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In `@R/deprecated.R`:
- Around line 415-430: The function find_common_prefix can loop forever for
length-0/1 vectors or when all filenames are identical; modify it so it first
handles short vectors (if length(vec) == 0 return "" ; if length(vec) == 1
return vec[1]) and compute a safe upper bound by using min(nchar(vec)) so the
while loop or its condition also stops once i > min_length; inside the loop keep
the existing unique(initial_bits) check but also break when i exceeds min_length
and return the accumulated lcs (or ""), referencing the existing symbols vec, i,
finish, lcs and the function name find_common_prefix to locate the code to
change.
- Around line 68-70: In .get_survey(), suppress the nested deprecation emitted
by download_survey() when survey is a character by wrapping the call to
download_survey(survey) so it does not show its deprecation warning (follow the
same pattern used in survey_countries() and get_citation()); keep the returned
value passed to load_survey() unchanged so new_survey <- load_survey(<suppressed
download_survey result>) preserves behavior while hiding the inner warning.

Co-authored-by: sbfnk-bot <242615673+sbfnk-bot@users.noreply.github.com>
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@R/deprecated.R`:
- Around line 418-424: The early-return guard clauses in the function
find_common_prefix are not braced; wrap each guard that returns early (the
checks for length(vec) == 0 and length(vec) == 1) in braces so they become
proper block statements (e.g., if (cond) { return(...) }) to satisfy the linter;
update the function around the initial guards (the two if checks) and ensure
formatting remains consistent.

Co-authored-by: sbfnk-bot <242615673+sbfnk-bot@users.noreply.github.com>
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR advances the deprecation cycle for Zenodo-related helpers in socialmixr, consolidating their implementations into a single deprecated module and reducing CI flakiness by removing tests that depend on Zenodo/network availability.

Changes:

  • Switched Zenodo-related functions to lifecycle::deprecate_warn() and consolidated them into R/deprecated.R.
  • Removed/updated tests: dropped Zenodo-hitting tests and replaced snapshot warning assertions with lifecycle::expect_deprecated().
  • Updated generated Rd files and NEWS entry to reflect the new deprecated source location and behavior.

Reviewed changes

Copilot reviewed 21 out of 21 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/testthat/test-surveys.r Removes Zenodo-dependent tests; updates deprecation assertion for get_citation().
tests/testthat/test-matrix.r Silences lifecycle warnings during setup; removes a Zenodo alignment test; minor option scoping changes.
tests/testthat/test-load-survey.R Removes a network-dependent download/load longitudinal test.
tests/testthat/test-download-survey.R Removes the (Zenodo-hitting) deprecation-warning snapshot test for download_survey().
tests/testthat/test-countries.r Switches deprecation test to lifecycle::expect_deprecated().
tests/testthat/_snaps/surveys.md Removes snapshots tied to deprecation warnings and Zenodo error cases.
tests/testthat/_snaps/download-survey.md Removes snapshot for download_survey() deprecation warning.
tests/testthat/_snaps/countries.md Removes snapshot for survey_countries() deprecation warning.
man/survey_countries.Rd Points documentation source to R/deprecated.R; updates argument text.
man/list_surveys.Rd Points documentation source to R/deprecated.R.
man/is_doi.Rd Points documentation source to R/deprecated.R.
man/get_survey.Rd Points documentation source to R/deprecated.R; updates ... description.
man/get_citation.Rd Points documentation source to R/deprecated.R.
man/download_survey.Rd Points documentation source to R/deprecated.R.
man/dot-get_survey.Rd Points documentation source to R/deprecated.R; updates ... description.
R/lists.R Removes deprecated Zenodo helpers from this module, leaving population listing functions.
R/get_survey.R Deletes old deprecated implementation (moved to R/deprecated.R).
R/download_survey.R Deletes old deprecated implementation (moved to R/deprecated.R).
R/cite.R Deletes old deprecated implementation (moved to R/deprecated.R).
R/deprecated.R New consolidated home for deprecated Zenodo functions and helpers; upgrades to deprecate_warn().
NEWS.md Documents the deprecation warning change and directs users to contactsurveys.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: sbfnk-bot <242615673+sbfnk-bot@users.noreply.github.com>
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Fix all issues with AI agents
In `@R/deprecated.R`:
- Line 116: The roxygen2 `@seealso` tag in deprecated.R is written as a regular
comment ("#  `@seealso` load_survey") so it is not parsed; change that line to a
roxygen comment by adding the leading apostrophe (for example "#' `@seealso`
load_survey"), keeping the reference to load_survey, so the `@seealso` directive
is recognized and appears in the generated documentation.
- Around line 418-441: find_common_prefix currently returns the full string when
vec has length 1, causing incorrect concatenation like "data.csvreference.json";
change the single-element branch in find_common_prefix to return an empty string
(""), or otherwise compute only the shared prefix up to a delimiter, so that
paste0(lcs, "reference.json") yields the intended filename; update the
function's length==1 case (in find_common_prefix) to return "" and ensure
existing callers handle an empty prefix.

In `@tests/testthat/test-surveys.r`:
- Around line 17-23: The nonportable_path_linter is incorrectly flagging the DOI
string literals in the test_that block (the vector passed to get_survey) because
they contain “/”; update the test to append “# nolint” to each DOI string
literal so the linter is suppressed for those lines (i.e., add # nolint after
"10.5281/zenodo.1095664" and "10.5281/zenodo.1127693" in the get_survey(...)
call) while leaving the rest of the test unchanged.
🧹 Nitpick comments (2)
R/deprecated.R (2)

448-450: A-z character range in regex includes unintended characters.

The range A-z covers ASCII 65–122, which includes six non-alphabetic characters ([, \, ], ^, `) between Z (90) and a (97). While this makes the regex more permissive rather than restrictive (so it won't reject valid DOIs), the canonical form is A-Za-z.

Suggested fix
-  is.character(x) && grepl("^10\\.[0-9.]{4,}/[-._;()/:A-z0-9]+$", x)
+  is.character(x) && grepl("^10\\.[0-9.]{4,}/[-._;()/:A-Za-z0-9]+$", x)

226-226: Inconsistent use of message() vs cli::cli_inform().

The rest of the file uses cli::cli_inform() for informational messages (e.g., line 212), but this line uses base message(). For consistency and to benefit from cli's formatting:

Suggested fix
-        message("Downloading ", zenodo_url)
+        cli::cli_inform("Downloading {.url {zenodo_url}}.")

Co-authored-by: sbfnk-bot <242615673+sbfnk-bot@users.noreply.github.com>
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@R/deprecated.R`:
- Around line 293-299: The current apply call building DOIs uses min(grep(...,
value = TRUE)) which returns Inf with a warning when grep yields character(0);
change the anonymous function (the one passed to apply over record_list) to
check the grep result first and return NA_character_ (or NA) when
length(matches) == 0, otherwise return the matched string (e.g., matches[1] or
min on a numeric index); specifically, replace
min(grep("^https://doi.org/.*zenodo", x[relations], value = TRUE)) with code
that assigns matches <- grep("^https://doi.org/.*zenodo", x[relations], value =
TRUE) and returns NA_character_ if length(matches) == 0 else matches[1] so DOIs
stays character and no Inf/warning is produced.
🧹 Nitpick comments (1)
R/deprecated.R (1)

118-236: Inconsistent logging: message() vs cli::cli_inform().

Line 212 uses cli::cli_inform() but line 226 uses bare message(). Since cli is already a dependency and used elsewhere in this function, consider using cli::cli_inform() consistently for user-facing messages. This also allows users to suppress output uniformly via cli's handler mechanism.

Suggested fix
-        message("Downloading ", zenodo_url)
+        cli::cli_inform("Downloading {.url {zenodo_url}}")

Co-authored-by: sbfnk-bot <242615673+sbfnk-bot@users.noreply.github.com>
@sbfnk
Copy link
Collaborator Author

sbfnk commented Feb 9, 2026

Addressed the two items from the latest coderabbit review:

  1. min(grep()) Inf warning in .list_surveys() - replaced with an explicit check that returns NA_character_ when no match is found, avoiding the Inf warning.
  2. Inconsistent logging - changed message() to cli::cli_inform() in download_survey() for consistency.

@sbfnk sbfnk added this pull request to the merge queue Feb 9, 2026
Merged via the queue into main with commit 31b6dec Feb 9, 2026
13 checks passed
@sbfnk sbfnk deleted the advance-deprecation branch February 9, 2026 18:06
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@R/deprecated.R`:
- Around line 33-37: Replace the versioned Zenodo DOI used in the examples
(lines showing peru_doi, peru_survey, and peru_data) with the Zenodo concept DOI
(e.g., 10.5281/zenodo.1157918) and update the comments around the example that
recommend using contactsurveys::download_survey so it notes the concept DOI
resolves to the latest version; ensure the same replacement is applied to other
occurrences referenced (e.g., in R/load_survey.R and lines 109-113, 342-345) and
keep the example calls to get_survey, download_survey, and load_survey
unchanged.

Comment on lines +33 to +37
#' peru_doi <- "https://doi.org/10.5281/zenodo.1095664"
#' peru_survey <- get_survey(peru_doi)
#' ## --> We now recommend:
#' peru_survey <- contactsurveys::download_survey(peru_doi)
#' peru_data <- load_survey(peru_survey)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Use the Zenodo concept DOI in examples.

The examples still use a versioned DOI. Please switch to the concept DOI and add a short note that it resolves to the latest version.

♻️ Suggested update
-#' peru_doi <- "https://doi.org/10.5281/zenodo.1095664"
+#' peru_doi <- "https://doi.org/10.5281/zenodo.1157918" # concept DOI resolves to latest version
...
-#' peru_survey <- download_survey("https://doi.org/10.5281/zenodo.1095664")
+#' peru_survey <- download_survey("https://doi.org/10.5281/zenodo.1157918") # concept DOI resolves to latest version
...
-#' doi_peru <- "10.5281/zenodo.1095664" # nolint
+#' doi_peru <- "10.5281/zenodo.1157918" # concept DOI resolves to latest version

Based on learnings: Use Zenodo concept DOIs (e.g., 10.5281/zenodo.1157918) in code examples and documentation so readers always access the latest dataset version without modifying code. Replace versioned or specific DOIs in examples (including R scripts like R/load_survey.R) with the concept DOI and include a brief note that it resolves to the latest version.

Also applies to: 109-113, 342-345

🤖 Prompt for AI Agents
In `@R/deprecated.R` around lines 33 - 37, Replace the versioned Zenodo DOI used
in the examples (lines showing peru_doi, peru_survey, and peru_data) with the
Zenodo concept DOI (e.g., 10.5281/zenodo.1157918) and update the comments around
the example that recommend using contactsurveys::download_survey so it notes the
concept DOI resolves to the latest version; ensure the same replacement is
applied to other occurrences referenced (e.g., in R/load_survey.R and lines
109-113, 342-345) and keep the example calls to get_survey, download_survey, and
load_survey unchanged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Complete migration of Zenodo functions to contactsurveys

2 participants