Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 10, 2026

Adds cachemap function to cache results of map operations, with optional per-element intermediate caching.

Implementation

  • Core function: cachemap(f, path, args...; cache_intermediates=false, mod=@__MODULE__)
    • Wraps map(f, args...) with result caching via nested cache() calls
    • When cache_intermediates=true, caches each element at path_i.bson before final result
    • Validates argument lengths and provides clear error messages

Usage

# Basic usage - caches final result only
cachemap(x -> expensive_computation(x), "results.bson", 1:1000)

# With intermediate caching - saves each element separately
# Useful when individual computations are expensive and you want to resume
cachemap(x -> expensive_computation(x), "results.bson", 1:1000; cache_intermediates=true)
# Creates: results_1.bson, results_2.bson, ..., results_1000.bson, results.bson

# Multiple arguments like map
cachemap(+, "sums.bson", [1,2,3], [4,5,6])  # [5, 7, 9]

Testing

Added 14 tests covering basic caching, intermediate caching, multiple arguments, and error handling.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/repos/JuliaCollections/DataStructures.jl/tarball/e357641bb3e0638d353c4b29ea0e40ea644066a6
    • Triggering command: /usr/bin/julia julia --project=. -e using Pkg; Pkg.test() (http block)
  • https://api.github.com/repos/JuliaCollections/OrderedCollections.jl/tarball/05868e21324cede2207c6f0f466b4bfef6d5e7ee
    • Triggering command: /usr/bin/julia julia --project=. -e using Pkg; Pkg.test() (http block)
  • https://api.github.com/repos/JuliaCollections/SortingAlgorithms.jl/tarball/64d974c2e6fdf07f8155b5b2ca2ffa9069b608d9
    • Triggering command: /usr/bin/julia julia --project=. -e using Pkg; Pkg.test() (http block)
  • https://api.github.com/repos/JuliaData/DataAPI.jl/tarball/abe83f3a2f1b857aac70ef8b269080af17764bbe
    • Triggering command: /usr/bin/julia julia --project=. -e using Pkg; Pkg.test() (http block)
  • https://api.github.com/repos/JuliaData/DataFrames.jl/tarball/d8928e9169ff76c6281f39a659f9bca3a573f24c
    • Triggering command: /usr/bin/julia julia --project=. -e using Pkg; Pkg.test() (http block)
  • https://api.github.com/repos/JuliaData/InvertedIndices.jl/tarball/6da3c4316095de0f5ee2ebd875df8721e7e0bdbe
    • Triggering command: /usr/bin/julia julia --project=. -e using Pkg; Pkg.test() (http block)
  • https://api.github.com/repos/JuliaData/Missings.jl/tarball/ec4f7fbeab05d7747bdf98eb74d130a2a2ed298d
    • Triggering command: /usr/bin/julia julia --project=. -e using Pkg; Pkg.test() (http block)
  • https://api.github.com/repos/JuliaData/PooledArrays.jl/tarball/36d8b4b899628fb92c2749eb488d884a926614d3
    • Triggering command: /usr/bin/julia julia --project=. -e using Pkg; Pkg.test() (http block)
  • https://api.github.com/repos/JuliaData/SentinelArrays.jl/tarball/ebe7e59b37c400f694f52b58c93d26201387da70
    • Triggering command: /usr/bin/julia julia --project=. -e using Pkg; Pkg.test() (http block)
  • https://api.github.com/repos/JuliaData/Tables.jl/tarball/f2c1efbc8f3a609aadf318094f8fc5204bdaf344
    • Triggering command: /usr/bin/julia julia --project=. -e using Pkg; Pkg.test() (http block)
  • https://api.github.com/repos/JuliaIO/BSON.jl/tarball/4c3e506685c527ac6a54ccc0c8c76fd6f91b42fb
    • Triggering command: /usr/bin/julia julia --project=. -e using Pkg; Pkg.test() (http block)
  • https://api.github.com/repos/JuliaLang/Compat.jl/tarball/9d8a54ce4b17aa5bdce0ea5c34bc5e7c340d16ad
    • Triggering command: /usr/bin/julia julia --project=. -e using Pkg; Pkg.test() (http block)
  • https://api.github.com/repos/JuliaLang/PrecompileTools.jl/tarball/07a921781cab75691315adc645096ed5e370cb77
    • Triggering command: /usr/bin/julia julia --project=. -e using Pkg; Pkg.test() (http block)
  • https://api.github.com/repos/JuliaPackaging/Preferences.jl/tarball/522f093a29b31a93e34eaea17ba055d850edea28
    • Triggering command: /usr/bin/julia julia --project=. -e using Pkg; Pkg.test() (http block)
  • https://api.github.com/repos/JuliaStats/Statistics.jl/tarball/ae3bb1eb3bba077cd276bc5cfc337cc65c3075c0
    • Triggering command: /usr/bin/julia julia --project=. -e using Pkg; Pkg.test() (http block)
  • https://api.github.com/repos/JuliaStrings/InlineStrings.jl/tarball/8f3d257792a522b4601c24a577954b0a8cd7334d
    • Triggering command: /usr/bin/julia julia --project=. -e using Pkg; Pkg.test() (http block)
  • https://api.github.com/repos/JuliaStrings/LaTeXStrings.jl/tarball/dda21b8cbd6a6c40d9d02a73230f9d70fed6918c
    • Triggering command: /usr/bin/julia julia --project=. -e using Pkg; Pkg.test() (http block)
  • https://api.github.com/repos/KristofferC/Crayons.jl/tarball/249fe38abf76d48563e2f4556bebd215aa317e15
    • Triggering command: /usr/bin/julia julia --project=. -e using Pkg; Pkg.test() (http block)
  • https://api.github.com/repos/queryverse/DataValueInterfaces.jl/tarball/bfc1187b79289637fa0ef6d4436ebdfe6905cbd6
    • Triggering command: /usr/bin/julia julia --project=. -e using Pkg; Pkg.test() (http block)
  • https://api.github.com/repos/queryverse/IteratorInterfaceExtensions.jl/tarball/a3f24677c21f5bbe9d2a714f95dcd58337fb2856
    • Triggering command: /usr/bin/julia julia --project=. -e using Pkg; Pkg.test() (http block)
  • https://api.github.com/repos/queryverse/TableTraits.jl/tarball/c06b2f539df1c6efa794486abfb6ed2022561a39
    • Triggering command: /usr/bin/julia julia --project=. -e using Pkg; Pkg.test() (http block)
  • https://api.github.com/repos/ronisbr/PrettyTables.jl/tarball/c5a07210bd060d6a8491b0ccdee2fa0235fc00bf
    • Triggering command: /usr/bin/julia julia --project=. -e using Pkg; Pkg.test() (http block)
  • https://api.github.com/repos/ronisbr/StringManipulation.jl/tarball/a3c1536470bf8c5e02096ad4853606d7c8f62721
    • Triggering command: /usr/bin/julia julia --project=. -e using Pkg; Pkg.test() (http block)
  • https://api.github.com/repos/simonster/Reexport.jl/tarball/45e428421666073eab6f2da5c9d310d99bb12f9b
    • Triggering command: /usr/bin/julia julia --project=. -e using Pkg; Pkg.test() (http block)
  • pkg.julialang.org
    • Triggering command: /usr/bin/julia julia --project=. -e using Pkg; Pkg.test() (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Add cachemap function</issue_title>
<issue_description>There are many cases where we cache the result of a map. Would be nice to have a function for that, with the option of caching the intermediate files along the way.</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@codecov
Copy link

codecov bot commented Jan 10, 2026

Codecov Report

❌ Patch coverage is 95.23810% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 98.11%. Comparing base (d3a9e1d) to head (35f4a01).

Files with missing lines Patch % Lines
src/CacheVariables.jl 95.23% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##            master      #15      +/-   ##
===========================================
- Coverage   100.00%   98.11%   -1.89%     
===========================================
  Files            1        1              
  Lines           32       53      +21     
===========================================
+ Hits            32       52      +20     
- Misses           0        1       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI and others added 4 commits January 10, 2026 19:55
Co-authored-by: dahong67 <9384655+dahong67@users.noreply.github.com>
Co-authored-by: dahong67 <9384655+dahong67@users.noreply.github.com>
Co-authored-by: dahong67 <9384655+dahong67@users.noreply.github.com>
Co-authored-by: dahong67 <9384655+dahong67@users.noreply.github.com>
Copilot AI changed the title [WIP] Add cachemap function for result caching Add cachemap function for cached mapping operations Jan 10, 2026
Copilot AI requested a review from dahong67 January 10, 2026 20:00
@dahong67 dahong67 closed this Jan 12, 2026
@dahong67
Copy link
Owner

After further thought, it feels like this form isn't quite necessary. Perhaps better to leave unimplemented and simply provide an example of this "pattern" in the README.

@dahong67 dahong67 deleted the copilot/add-cachemap-function branch January 12, 2026 21:41
@dahong67
Copy link
Owner

Superseded by #17

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.

Add examples of map patterns

2 participants