Global const dataframe

I’ve got a module DataManagment with a module global main_dataframe defined as such:
global const main_dataframe = DataFrame()
I’m using it to have a main store of data for a series of experiments. But when I access it from the experiment:
include(“DataManagement.jl”)
using .DataManagement
push!(main_dataframe, named_tuple_of_data)
the dataframe does not appear to update. If I
return main_dataframe
it gives me back an updated dataframe, but when I look at DataManagement.main_dataframe, the dataframe is still empty. What am I doing wrong? Is this the best way to do what I’m trying to do?
Thanks,
–Markos

What you’ve written there should work, but it’s obviously not the whole situation. I would check to make sure that you’re not shadowing the main_dataframe that’s implicitly imported by the using DataManagement with another — completely independent! — local with the same name.

1 Like

I’ve made every call to main_dataframe explicitly DataManagement.main_dataframe. Nonetheless, it still returns the updated dataframe (as a check) but DataManagement.main_dataframe is still a properly defined frame, with all the right fields, but remains empty.

This is odd enough to warrant a MWE. For instance, it’s not obvious where a return main_dataframe would even be applicable here, there’s no method. If it helps, you can check whether the dataframe assigned to DataManagement.main_dataframe and the returned dataframe are the same with ===.

I seem to have figured it out. The problem was multiple includes clobbering the namespace. So, a followup question: best practices seem to be to only include in your top level file, export all variables and functions you want to have accessed internally, and access from other modules as using Main.MyModule. Is this correct? Is there another way of going about this that’s more safe, or even more Julia-like?