dhmit / gender_analysis

A toolkit for analyzing gendered language across sets of documents
BSD 3-Clause "New" or "Revised" License
11 stars 5 forks source link

pickle functionality should save pickle files to script location, not gender_analysis #45

Closed sophiazhi closed 5 years ago

sophiazhi commented 5 years ago

used BASE_PATH in common.store_pickle and common.load_pickle

ryaanahmed commented 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.

sophiazhi commented 5 years ago

Agreed -- the title of this issue is the problem in our code, not what I think we should implement (sorry for the confusion)

ryaanahmed commented 5 years ago

ah! totally misunderstood.

ryaanahmed commented 5 years ago

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).

samimak37 commented 5 years ago

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?

ryaanahmed commented 5 years ago

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.

ryaanahmed commented 5 years ago

done! thanks all.