UPDATE The behaviour no longer occurs in version 10.3.
Here are minimal reproduction steps, from a fresh 10.2.0 kernel:
Module[{data = {{1}}}, data // Dataset // Transpose]
(*
data::shdw: Symbol data appears in multiple contexts {Streaming`LazyList`Testing`,Global`};
definitions in context Streaming`LazyList`Testing` may shadow or
be shadowed by other definitions. >>
*)
After executing this, the $ContextPath
looks suspicious:
$ContextPath
(* {"Streaming`LazyList`Testing`", "Streaming`", "StreamingLoader`",
"IconizeLoader`", "CloudObjectLoader`", "PacletManager`",
"System`", "Global`"} *)
Diagnosis
Upon further investigation, the problem appears to involve two causes. First, the streaming framework unconditionally loads and executes its test suite, adding it to the context path. To see this, inspect the following file:
NotebookOpen @ FileNameJoin @
{"SystemFiles","Components","Streaming","StreamingLoader.m"}
... and note the following lines near the top:
Get[FileNameJoin[{DirectoryName[$InputFileName],"TestDSL.m"}]];
Block[{$ContextPath},
Get[FileNameJoin[{DirectoryName[$InputFileName],"Tests.m"}]]
]
The second cause appears to be related to a cyclic dependency between the Streaming`
and Dataset`
packages (and possible between other packages as well). Dataset`$AvailableBackends
contains an implicit reference to Streaming`CachedObject
, triggering a load via Package`ActivateLoad
. The Streaming`
package, in turn, has an explicit dependency upon the Dataset`
package.
Normally, the act of auto-loading a package makes no changes to the $ContextPath
. The presence of cyclic dependencies has historically interfered with the preservation of this path, so I suspect that it is at least part of the problem here.
Partial Workaround
The effects of both problems can be reduced by pre-loading the Streaming`
package as the first action of a new kernel session:
Quiet @ Block[{$ContextPath}, Needs["Streaming`"]]
This preloading action leaves us with a cleaner environment:
Module[{data = {{1}}}, data // Dataset // Transpose]
(* Dataset[...] *)
$ContextPath
(* {"StreamingLoader`", "IconizeLoader`", "CloudObjectLoader`",
"PacletManager`", "System`", "Global`"} *)
The observant reader will have noticed the presence of Quiet
in the preloading step. It is needed to suppress another symbol conflict between System`ToCamelCase
and GeneralUtilities`ToCamelCase
. It would appear that there are similar auto-loading issues elsewhere. Therefore this solution can only really be considered as a partial work-around.
Streaming`LazyList`Testing`
should not be on the$ContextPath
, but this is certainly not a proper behavior (I am the developer of Streaming module). I will look into this, but it would be easier to do with some code reproducing the problem. $\endgroup$,IconizeLoader
,CloudObjectLoader,PacletManager
,System,Global
} and I've just seen a variant where its a collision with a temporary symbol... data\$::shdw: Symbol data\$ appears in multiple contexts {StreamingLazyList
Testing` ,Global` }; $\endgroup$