Function Repository Resource:

WithDatedResourceFunctions

Source Notebook

ResourceFunction time machine

Contributed by: Nikolay Murzin

ResourceFunction["WithDatedResourceFunctions"][date,code]

runs the code assuming latest ResourceFunction versions as existed on the specified date.

ResourceFunction["WithDatedResourceFunctions"][date]

represents an operator form of ResourceFunction["WithDatedResourceFunctions"] that can be applied to a code.

Details

Only uninitialized resource functions are affected.
ResourceFunction["WithDatedResourceFunctions"] has the attribute HoldFirst.
ResourceFunction["WithDatedResourceFunctions"][date][Unevaluated[code]] prevents the evaluation of code outside of the scope of dated resource functions.

Examples

Basic Examples (3) 

Check the version of a ResourceFunction:

In[1]:=
Information[ResourceFunction["NestGraphTagged"], "Version"]
Out[1]=

Run code where the ResourceFunction is temporarily downgraded to the latest version as of the specified date:

In[2]:=
ResourceFunction["WithDatedResourceFunctions"][
 DateObject[{2022}],
 Information[ResourceFunction["NestGraphTagged"], "Version"]
 ]
Out[2]=

Outside of WithDatedResourceFunctions the original version is maintained:

In[3]:=
Information[ResourceFunction["NestGraphTagged"], "Version"]
Out[3]=

The code can contain multiple resource functions:

In[4]:=
ResourceFunction["WithDatedResourceFunctions"][
 DateObject[{2021, 11, 10}],
 {
  Information[ResourceFunction["GraphFoliations"], "Version"],
  Information[ResourceFunction["NestGraphTagged"], "Version"]
  }
 ]
Out[4]=

Use the operator form:

In[5]:=
Unevaluated@
  Information[ResourceFunction["NestGraphTagged"], "Version"] // ResourceFunction["WithDatedResourceFunctions"][DateObject[{2021}]]
Out[5]=

Possible Issues (2) 

A ResourceFunction with old versions and a missing creation date will always return the latest version:

In[6]:=
Information[ResourceFunction["BirdSay"], "AllVersions"]
Out[6]=
In[7]:=
ResourceFunction["WithDatedResourceFunctions"][
 DateObject[{2018}],
 Information[ResourceFunction["BirdSay"], "Version"]
 ]
Out[7]=

An initialized ResourceFunction object is not affected:

In[8]:=
ResourceFunction["WithDatedResourceFunctions"][
 DateObject[{2021, 11, 10}],
 Information[ResourceFunction[
ResourceObject[<|"Name" -> "GraphFoliations", "ShortName" -> "GraphFoliations", "UUID" -> "4498d0f3-d0f5-4e29-b682-703d0e650173", "ResourceType" -> "Function", "Version" -> "1.3.0", "Description" -> "Enumerate possible foliations of a directed acyclic graph", "RepositoryLocation" -> URL[
      "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"], "SymbolName" -> "FunctionRepository`$581077e9a7584de7903f4ecfe30c99b5`GraphFoliations", "FunctionLocation" -> CloudObject[
      "https://www.wolframcloud.com/obj/5b298d84-ef0d-44d2-be12-1f84f65f6d13"]|>, ResourceSystemBase -> Automatic]], "Version"]
 ]
Out[8]=

Use the name to specify the resource function to ensure dated versions:

In[9]:=
ResourceFunction["WithDatedResourceFunctions"][
 DateObject[{2021, 11, 10}],
 Information[ResourceFunction["GraphFoliations"], "Version"]
 ]
Out[9]=

Version History

  • 1.0.0 – 01 November 2022

Related Resources

License Information