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

Add felix.kitchen #1098

Merged
merged 8 commits into from
May 7, 2024
Merged

Add felix.kitchen #1098

merged 8 commits into from
May 7, 2024

Conversation

mlduff
Copy link
Contributor

@mlduff mlduff commented Apr 26, 2024

This PR adds support for felix.kitchen, using https://felix.kitchen/2024/04/07/piccata-milanese-schnitzel-parmesan-safran-risotto-petersilie/ as the test recipe.
Couldn't find total_time on any recipe on the website, so have this returning None.

Resolves #1063

@mlduff
Copy link
Contributor Author

mlduff commented Apr 27, 2024

Thanks for the review, comments should be addressed now @jayaddison

@mlduff mlduff requested a review from jayaddison April 27, 2024 04:46
Comment on lines 25 to 26
def total_time(self):
return None
Copy link
Collaborator

Choose a reason for hiding this comment

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

We may want to emit a Python warning here, if we know that we're never going to find results for this field on this website.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jayaddison I've been following #1067, I'm not 100% sure what the verdict on the way you want this implemented is?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not certain either; whatever approach we choose, I want it to be simple (no more than a few lines), and minimally disruptive, because I think it's somewhat experimental but potentially useful information.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jayaddison I've now updated this with my attempt at an approach to warnings that allows for the warning to be silenced during testing.

recipe_scrapers/_utils.py Outdated Show resolved Hide resolved
Co-authored-by: Joey <7505194+jknndy@users.noreply.github.com>
@@ -274,3 +281,14 @@ def change_keys(obj, convert):
def get_url_slug(url):
path = url_path_to_dict(url).get("path")
return path.split("/")[-1]


def unsupported_field_warning(host, field):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Recommend following the same approach as #1077 for this; only implement for the affected scraper, not as a _utils` module feature yet.

It probably makes sense to share a common code path for these kind of warnings at some point, but let's begin simple.

return normalize_string(found.get("content"))

def total_time(self):
field_not_provided_by_website_warning(self.host(), "total_time")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ok, yep - this is getting closer to a good interface I think.

I'd be tempted to suggest that in fact, this should be implemented as an exception. So all that a new developer needs to know is: raise the correct type of exception.

def total_time(self);
    raise FieldNotProvidedByWebsiteException()

...and then we'd have plugin -- enabled by default -- to emit a warning when that exception is raised.

That way, if some downstream consumer really wants to handle cases where the website doesn't ever provide data for a field, they can do so.

(that's not possible -- or not easily possible -- using warnings alone, because they don't affect the return value/behaviour of the method)

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm going to merge this as-is, but I think we can and should refactor this in the nearish future.

@jayaddison jayaddison merged commit dffa84b into hhursev:main May 7, 2024
18 checks passed
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.

[Add] Felix.kitchen scraper
3 participants