Skip to content

Add cached function returning output and metadata#32

Merged
dahong67 merged 18 commits intomasterfrom
copilot/add-cached-function
Jan 28, 2026
Merged

Add cached function returning output and metadata#32
dahong67 merged 18 commits intomasterfrom
copilot/add-cached-function

Conversation

Copy link
Contributor

Copilot AI commented Jan 28, 2026

Implementation Changes

  • Remove log messages from cached function
  • Rework cache to use cached internally
  • Update tests to remove log assertions for cached
  • Verify both functions work correctly
  • Add brief example of cached to README

Summary

The cached function now operates silently without log messages, returning only the NamedTuple with value and metadata. The cache function has been refactored to call cached internally, adding the log messages on top before returning just the value. This eliminates code duplication while maintaining the same behavior for cache.

A brief example demonstrating the cached function has been added to the README at the end of the "Function form" section.

Original prompt

This section details on the original issue you should resolve

<issue_title>Create new cached function</issue_title>
<issue_description>Could be interesting to add a cached function that returns both the output and the metadata, somewhat analogous to @time vs @timed.

Could be useful in the future for defining some sort of cachemap that accumulates the metadata from the "intermediate" cache files. Could also be "nicer" for unit testing since we wouldn't need to read the BSON/JLD2 files to check what's been saved.</issue_description>

<agent_instructions>Focus first on implementing just the cached function. It should return the outputs together with the metadata, in an analogous way to @timed. Don't worry about the cachemap stuff - that can always be done in the future if the need arises.</agent_instructions>

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


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 3 commits January 28, 2026 13:59
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 new cached function to return output and metadata Add cached function returning output and metadata Jan 28, 2026
Copilot AI requested a review from dahong67 January 28, 2026 14:16
Copy link
Owner

@dahong67 dahong67 left a comment

Choose a reason for hiding this comment

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

@copilot good progress, now let's work on two items

  • drop log messages from cached
  • rework cache to use cached internally

Co-authored-by: dahong67 <9384655+dahong67@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 28, 2026

@copilot good progress, now let's work on two items

  • drop log messages from cached
  • rework cache to use cached internally

Done in commit a49988e:

  1. Dropped log messages from cached: The cached function now operates silently, returning only the NamedTuple with value and metadata
  2. Reworked cache to use cached internally: The cache function now calls cached and adds log messages before returning just the value

This eliminates code duplication while maintaining the same user-facing behavior for cache.

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/FluxML/MacroTools.jl/tarball/1e0228a030642014fe5cfe68c2c0a818f9e3f522
    • Triggering command: /usr/bin/julia julia --project=. -e using Pkg; Pkg.test() (http block)
  • https://api.github.com/repos/JuliaBinaryWrappers/Zstd_jll.jl/tarball/446b23e73536f84e8037f5dce465e92275f6a308
    • Triggering command: /usr/bin/julia julia --project=. -e using Pkg; Pkg.test() (http block)
  • 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/JuliaIO/ChunkCodecs.jl/tarball/1a3ad7e16a321667698a19e77362b35a1e94c544
    • Triggering command: /usr/bin/julia julia --project=. -e using Pkg; Pkg.test() (http block)
  • https://api.github.com/repos/JuliaIO/ChunkCodecs.jl/tarball/34d9873079e4cb3d0c62926a225136824677073f
    • Triggering command: /usr/bin/julia julia --project=. -e using Pkg; Pkg.test() (http block)
  • https://api.github.com/repos/JuliaIO/ChunkCodecs.jl/tarball/cee8104904c53d39eb94fd06cbe60cb5acde7177
    • Triggering command: /usr/bin/julia julia --project=. -e using Pkg; Pkg.test() (http block)
  • https://api.github.com/repos/JuliaIO/FileIO.jl/tarball/d60eb76f37d7e5a40cc2e7c36974d864b82dc802
    • Triggering command: /usr/bin/julia julia --project=. -e using Pkg; Pkg.test() (http block)
  • https://api.github.com/repos/JuliaIO/JLD2.jl/tarball/8f8ff711442d1f4cfc0d86133e7ee03d62ec9b98
    • 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/JuliaLang/ScopedValues.jl/tarball/c3b2323466378a2ba15bea4b2f73b081e022f473
    • Triggering command: /usr/bin/julia julia --project=. -e using Pkg; Pkg.test() (http block)
  • https://api.github.com/repos/JuliaPackaging/JLLWrappers.jl/tarball/0533e564aae234aff59ab625543145446d8b6ec2
    • 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/JuliaPackaging/Requires.jl/tarball/62389eeff14780bfe55195b7204c0d8738436d64
    • Triggering command: /usr/bin/julia julia --project=. -e using Pkg; Pkg.test() (http block)
  • https://api.github.com/repos/JuliaPluto/ExpressionExplorer.jl/tarball/4a8c0a9eebf807ac42f0f6de758e60a20be25ffb
    • 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/JuliaTesting/Aqua.jl/tarball/d57fd255a8932b6509baf43284c416fc44d0b903
    • Triggering command: /usr/bin/julia julia --project=. -e using Pkg; Pkg.test() (http block)
  • https://api.github.com/repos/JuliaTesting/ExplicitImports.jl/tarball/a8b6c26bf0ea9f8c4bad71e109a5fa64f34be392
    • 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/julia-vscode/TestItemRunner.jl/tarball/76f275a3f3d83ece88ec69d73058048de5acb1dc
    • Triggering command: /usr/bin/julia julia --project=. -e using Pkg; Pkg.test() (http block)
  • https://api.github.com/repos/julia-vscode/TestItems.jl/tarball/42fd9023fef18b9b78c8343a4e2f3813ffbcefcb
    • 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)
  • https://api.github.com/repos/vchuravy/HashArrayMappedTries.jl/tarball/2eaa69a7cab70a52b9687c8bf950a5a93ec895ae
    • 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:

Copilot AI requested a review from dahong67 January 28, 2026 14:33
@codecov
Copy link

codecov bot commented Jan 28, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (1e00083) to head (c2fe6f6).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##            master       #32   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            3         3           
  Lines           57        72   +15     
=========================================
+ Hits            57        72   +15     

☔ 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.

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Copy link
Owner

@dahong67 dahong67 left a comment

Choose a reason for hiding this comment

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

@copilot I've gone through and revised/polished. I think these are now good to go! One thing left to do is to add a very brief example of this to the README. Add it to the end of the "Function form" section. Please do not modify any other files at this point, only README.md.

Co-authored-by: dahong67 <9384655+dahong67@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 28, 2026

@copilot I've gone through and revised/polished. I think these are now good to go! One thing left to do is to add a very brief example of this to the README. Add it to the end of the "Function form" s...

Added in commit 9170f9d. I've added a brief example of the cached function at the end of the "Function form" section in README.md, showing how it returns metadata along with the value.

Copilot AI requested a review from dahong67 January 28, 2026 16:33
Copy link
Owner

@dahong67 dahong67 left a comment

Choose a reason for hiding this comment

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

Looks good, I think we're all set!

@dahong67 dahong67 marked this pull request as ready for review January 28, 2026 16:40
@dahong67 dahong67 merged commit 92c8e8a into master Jan 28, 2026
9 checks passed
@dahong67 dahong67 deleted the copilot/add-cached-function branch January 28, 2026 16:43
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.

Create new cached function

2 participants