From 8f08555f287b135e852894ef5c01d3fb3869cad2 Mon Sep 17 00:00:00 2001 From: Valentin Churavy Date: Mon, 21 Aug 2023 18:42:40 -0400 Subject: [PATCH] Switch from ContextVariablesX to ScopedValues --- Project.toml | 4 ++-- src/Checkpoints.jl | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Project.toml b/Project.toml index 58fa0e7..208b4ae 100644 --- a/Project.toml +++ b/Project.toml @@ -6,20 +6,20 @@ version = "0.3.21" [deps] AWSS3 = "1c724243-ef5b-51ab-93f4-b0a88ac62a95" Compat = "34da2185-b29b-5c13-b0c7-acf172513d20" -ContextVariablesX = "6add18c4-b38d-439d-96f6-d6bc489c04c5" DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8" Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b" FilePathsBase = "48062228-2e41-5def-b9a4-89aafe57970f" JLSO = "9da8a3cd-07a3-59c0-a743-3fdc52c30d11" Memento = "f28f55f0-a522-5efc-85c2-fe41dfb9b2d9" OrderedCollections = "bac558e1-5e72-5ebc-8fee-abe8a469f55d" +ScopedValues = "7e506255-f358-4e82-b7e4-beb19740aa63" [compat] AWS = "1" AWSS3 = "0.8, 0.9, 0.10" Compat = "3.15, 4" -ContextVariablesX = "0.1.1" DataStructures = "0.17, 0.18" +ScopedValues = "1.0" FilePathsBase = "0.6, 0.7, 0.8, 0.9" JLSO = "2" Memento = "0.10, 0.11, 0.12, 0.13, 1" diff --git a/src/Checkpoints.jl b/src/Checkpoints.jl index 5944ad6..4c7b630 100644 --- a/src/Checkpoints.jl +++ b/src/Checkpoints.jl @@ -9,7 +9,7 @@ module Checkpoints using AWSS3 using Compat # for contains (julia v1.5) -using ContextVariablesX +using ScopedValues using DataStructures: DefaultDict using FilePathsBase using FilePathsBase: /, join @@ -30,7 +30,7 @@ __init__() = Memento.register(LOGGER) include("handler.jl") const CHECKPOINTS = Dict{String, Union{Nothing, String, AbstractHandler}}() -@contextvar CONTEXT_TAGS::Tuple{Vararg{Pair{Symbol, Any}}} = Tuple{}() +const CONTEXT_TAGS = ScopedValue{Tuple{Vararg{Pair{Symbol, Any}}}}(Tuple{}()) include("session.jl") include("indexing.jl") @@ -58,7 +58,7 @@ allowed, including the tags provided directly in the [`checkpoint`](@ref) call. Duplicate tags are repeated, not overwritten. """ function with_checkpoint_tags(f::Function, context_tags::Pair...) - with_context(f, CONTEXT_TAGS => (CONTEXT_TAGS[]..., context_tags...)) + scoped(f, CONTEXT_TAGS => (CONTEXT_TAGS[]..., context_tags...)) end with_checkpoint_tags(f::Function, context_tags::NamedTuple) = with_checkpoint_tags(f, pairs(context_tags)...)