Closed sophiazhi closed 5 years ago
@sophiazhi -- if I understand this correctly, I think this is probably the opposite of the behavior we want.
Remember: users of the module will not have ready access to the gender_analysis root directory. They'll have installed it via pip, and chances are they won't actually even know where it is (i.e., in the site-packages directory of their virtual environment, or in the site-packages directory of their Python installation).
Pickles should probably be saved wherever the user is running their script by default, and we should probably allow the user to specify a pickle file path whenever we give the option to save a pickle.
Agreed -- the title of this issue is the problem in our code, not what I think we should implement (sorry for the confusion)
ah! totally misunderstood.
My usual practice is to describe what needs to happen in the issue title (so the issue list reads like a TODO list) and then describe the current behavior in the comment. That's not a hard and fast rule, but let's do that for this project (i.e., please modify accordingly).
I'm currently working on a potential fix to this, but there are two directions I can take it:
1) common.store_pickle
accepts a fully-fledged Path to wherever the user wants to keep the pickled data
2) Instead of passing in a file path as a parameter, store_pickle
instead only takes in a filename, and stores everything into a pickle_data
directory in the user's project branch
Thoughts?
We should support both -- but we get this more-or-less get this for free, if we just pass what the user inputs for the filepath into our file writing routine. If it's a relative path, or just a filename, we put it relative to the user's working directory, if it's an absolute path, we follow that.
e.g.,
def some_analysis_function(pickle_filename):
# do some stuff
with open(pickle_filename, w) as out_file:
# write a pickle
if the user passes 'some_filename' as pickle_filename, that'll be relative to the user's current working directory. If the user passes an absolute filepath '/some/path/to/here', that'll be absolute. We don't have to do anything to get that, as long as we pass their input around correctly.
done! thanks all.
used BASE_PATH in common.store_pickle and common.load_pickle