Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide script that downloads netflix prize data and puts it in the right place #56

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

JamesKohlsRepo
Copy link
Collaborator

@JamesKohlsRepo JamesKohlsRepo commented Dec 13, 2024

Fixes #43

these are intended to be run as pipenv scripts:
pipenv run download_data
pipenv run delete_data

they can also be run from file
@audiodude audiodude changed the title Issue 43 provide script that downloads netflix prize data and puts it in the right place Provide script that downloads netflix prize data and puts it in the right place Dec 13, 2024
Copy link
Collaborator

@audiodude audiodude left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great!

When you merge main, go ahead and delete the Pipfile.lock file. Then merge your changes to Pipfile, and run pipenv install. That will regenerate a fresh Pipfile.lock. The file is machine generated and not intended to be merged by hand.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file needs to be merged with main. It should be simple, just keep everything that main added, and add your new dependencies and scripts.

ruff = "~=0.7"
tqdm = "~=4.66"
requests = "*"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should leave the existing requests dependency.


[dev-packages]
pytest = "~=8.3"
pytest-cov = "~=5.0"

[requires]
python_version = "3.12"

[scripts]
download_data = "python download_data.py"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These need to be pipenv run python -m mediabridge.download_data. The pipenv run is needed to make the scripts run in the pipenv environment.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would recommend moving these scripts to the top level, not under the mediabridge module. The reasoning is that they are utilities for helping set up the environment, not a part of our software/library.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might be a bit overkill, because folks could just run rm -rf data to remove the data dir, and your download script will recreate it right?

import wget

"""
For our scripts to work, we need to download the Netflix prize data. As this file is ~500 MB and the licensing terms are dubious, we decided early on not to include it as part of the repo. It is however available on the Internet Archive here: https://archive.org/details/nf_prize_dataset.tar
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this comment only needs the first paragraph. The rest is a description of how to write this very script.



if __name__ == "__main__":
url = "https://archive.org/download/nf_prize_dataset.tar/nf_prize_dataset.tar.gz"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not necessary, but the usual pattern is to do:

def main():
   url = ...
   ...
   download_file(...)
   extract_file()

if __name__ == "__main__":
   main()

The main reason (see what I did there?) is that you might later add logic for handling command line args or other things, that are independent of the functionality of the main() function itself. Also, if you make main() its own function, it can be called from other scripts/modules (if that is ever useful).

ruff = "~=0.7"
tqdm = "~=4.66"
requests = "*"
wget = "*"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, please specify a loose version requirement, like the other libraries in this file.

wget = "~=9.9"

Or whatever the current major/minor version is. You can get it off pypi, or with pipenv run pip freeze. Don't specify the patch version (so 9.9, not 9.9.9), so that we are pegged to the major version and the minor version can increment (versus being pegged to the minor version and only the patch version can increment). For more information see https://semver.org/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Provide script that downloads Netflix prize data and puts it in the right place
2 participants