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

scrapy-spider-metadata support. #75

Merged
merged 7 commits into from
Sep 29, 2023
Merged

scrapy-spider-metadata support. #75

merged 7 commits into from
Sep 29, 2023

Conversation

wRAR
Copy link
Member

@wRAR wRAR commented Sep 26, 2023

No description provided.

@codecov
Copy link

codecov bot commented Sep 26, 2023

Codecov Report

Attention: 13 lines in your changes are missing coverage. Please review.

Comparison is base (71aacd8) 95.58% compared to head (8b4d3dd) 93.94%.

❗ Current head 8b4d3dd differs from pull request most recent head 4d4c5ac. Consider uploading reports for the commit 4d4c5ac to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master      #75      +/-   ##
==========================================
- Coverage   95.58%   93.94%   -1.64%     
==========================================
  Files          15       15              
  Lines         747      760      +13     
==========================================
  Hits          714      714              
- Misses         33       46      +13     
Files Coverage Δ
sh_scrapy/commands/shub_image_info.py 47.22% <0.00%> (-26.70%) ⬇️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@wRAR
Copy link
Member Author

wRAR commented Sep 26, 2023

I haven't added tests because the project doesn't currently test the command output either. It also needs a Scrapy project, which is possible (we generate Scrapy projects in tests in other libraries).

setup.py Outdated Show resolved Hide resolved
# make sure it's serializable
json.dumps(metadata_dict)
except (TypeError, ValueError):
continue
Copy link
Member

Choose a reason for hiding this comment

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

should we have a warning here?

Copy link
Member Author

Choose a reason for hiding this comment

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

The command prints a JSON text which some other components read, we could print warnings to stderr but I don't think anything will read them (but I'm not sure).

Copy link
Member

Choose a reason for hiding this comment

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

Still, it seems currently it's the only place where the error could be show; without it there is no indication of issue at all. But maybe there is a better place for it?

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 tried to do that and found that the command explicitly disables logging:

default_settings = {'LOG_ENABLED': False}

Copy link
Member

Choose a reason for hiding this comment

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

We might need to find another place to log these errorrs, or document it (in scrapy-spider-metadata?). But it seems this shouldn't block this PR.

@wRAR
Copy link
Member Author

wRAR commented Sep 26, 2023

OK, I guess we need a test because the initially pushed code didn't work correctly.

tests/test_crawl.py Outdated Show resolved Hide resolved
sh_scrapy/commands/shub_image_info.py Outdated Show resolved Hide resolved
sh_scrapy/commands/shub_image_info.py Outdated Show resolved Hide resolved
try:
from scrapy_spider_metadata import get_spider_metadata
except ImportError:
pass
Copy link
Member

Choose a reason for hiding this comment

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

It seems we lack tests on CI which check a case where the library is not installed

Copy link
Member Author

Choose a reason for hiding this comment

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

3.6 and 3.7 :)

Copy link
Member

Choose a reason for hiding this comment

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

Why isn't this line detected as covered?

Copy link
Member Author

Choose a reason for hiding this comment

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

None of run() is detected as covered: https://app.codecov.io/github/scrapinghub/scrapinghub-entrypoint-scrapy/commit/ebf23f19ff3bc1853a35f001a8b2df7e1b1ec63b/blob/sh_scrapy/commands/shub_image_info.py

Not sure if codecov can detect coverage for code run as a separate process.

@wRAR wRAR closed this Sep 29, 2023
@wRAR wRAR reopened this Sep 29, 2023
@elacuesta elacuesta merged commit 1cc4352 into master Sep 29, 2023
15 of 20 checks passed
@elacuesta elacuesta deleted the spider-metadata branch September 29, 2023 17:49
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.

4 participants