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

feat: add support for downloading obsolete product dump in ProductDataset #281

Merged

Conversation

areebahmeddd
Copy link
Member

Description

Currently, the ProductDataset class does not support downloading the obsolete product dump. This feature allows users to access the obsolete product data from Open Food Facts.

Solution

Added support for downloading the obsolete product dump in ProductDataset. Introduced a new DatasetType.obsolete and updated relevant functions to handle this dataset.

Related issue(s)

@areebahmeddd areebahmeddd requested a review from a team as a code owner November 2, 2024 12:01
@raphodn
Copy link
Member

raphodn commented Nov 2, 2024

Tested locally, it works !

from openfoodfacts import ProductDataset, DatasetType, Flavor

dataset = ProductDataset(
    flavor=Flavor.off,
    dataset_type=DatasetType.obsolete,
    force_download=True,
    download_newer=True,
)

/home/raphael/.cache/openfoodfacts/datasets/openfoodfacts-products_obsolete.jsonl.gz: 100%|███████████████████████████████████████████████████████████████████████████████████| 88.5M/88.5M [00:01<00:00, 71.2MB/s]

dataset.count()
// 24790

@@ -870,6 +870,7 @@ def check_user_agent(self):
class DatasetType(str, enum.Enum):
csv = "csv"
jsonl = "jsonl"
obsolete = "obsolete"
Copy link
Member

Choose a reason for hiding this comment

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

technically, its a jsonl type.. so maybe rename to obsolete_jsonl instead ?
I'll let @raphael0202 decide

Copy link
Contributor

Choose a reason for hiding this comment

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

I would rather add an obsolete parameter to the function that having a new dataset type. It does not really make sense here to add obsolete as dataset type, as dataset type currently indicates the export format.

Copy link
Member

@raphodn raphodn Nov 3, 2024

Choose a reason for hiding this comment

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

i also think an additional parameter is more logical.
1 possible issue : it currently only applies to the off flavor

Copy link
Member Author

Choose a reason for hiding this comment

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

I've updated the implementation to use an obsolete parameter instead of adding a new DatasetType. Please review the changes! @raphael0202

Thanks

Copy link

sonarqubecloud bot commented Nov 4, 2024

Copy link
Member

@alexgarel alexgarel left a comment

Choose a reason for hiding this comment

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

Thanks !

@raphael0202 raphael0202 merged commit d844fe4 into openfoodfacts:develop Nov 4, 2024
5 checks passed
@areebahmeddd areebahmeddd deleted the feat/add-obsolete-product-dump branch November 4, 2024 09:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

ProductDataset: allow downloading the products obsolete dump
4 participants