Enhancement: Inversion of control scraper base class
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 5/5
- Tempo estimado
- Mais de uma semana
- Facilidade para iniciantes
- 25/100
Direção de pesquisa
Comece revisando as abstrações de scraper existentes e o trabalho do scraper do DevDocs descrito na issue; nenhum arquivo ou teste específico é nomeado. Defina uma classe base reutilizável que cubra a configuração compartilhada, como cache, flags de CLI, metadados do Zim, logging, acompanhamento do progresso e acesso HTTP, e então verifique se um scraper pode usá-la com menos configuração e testes duplicados.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
When recently building the DevDocs scraper, I realized there are a ton of things that I was relying on @benoit74's expertise for to make the scraper sustainable for ZimFarm but weren't core to building a functional scraper. These include:
- Caching if S3 is available.
- Expected CLI flags.
- Zim file parameters/naming/destinations.
- ZimFarm operator friendly logging setup.
- Progress tracker.
- HTTP client setup.
The scraper still isn't fully there, but I've already spent a lot of time implementing and testing some of these things. I've written Logstash plugins and Elastic Beats (which are more smiilar to Zim scrapers and those were dramatically easier because that common logic was abstracted away.
I'd love to see something like the following (example only!) as what I had to build while knowing most of the above would be taken care of:
# New type ZimMetadata contains the properties to populate config_metadata() on a Zim.
# There are specific types based on whether the scraper is for a single Zim or multiple (in which case
# it supports placeholders).
# Methods can be overridden for fine-grained control e.g. to add additional formatting parameters.
M = TypeVar('M', bound=ZimMetadata)
class MyScraper(MultiZimScraper):
# Parent class includes a logger, HTTP client, potentially other items.
def add_flags(parser: argparse.ArgumentParser):
'''Add custom flags to the program'''
pass
def setup(namespace: argparse.Namespace):
'''Parse flags and set up resources for execution.
After this call, MultiZimScraper may have additional internal variables set up
e.g. an HTTP client that automatically caches to S3 if running in ZimFarm and with
retries/delay.
'''
pass
def list_zims() -> M:
'''Called after setup to list all Zims to be created. '''
pass
def add_contents(creator: Creator, metadata: M):
'''Called for each item in list_zims().
The JSON progress file is updated between calls, logs for progress/next ZIM/timing are written
and a scraper check utility could be asserted after.
'''
pass
I don't think all scrapers would need to use this format, but something like it would have dramatically cut down on the amount of testing and knowledge needed for me to produce a quality Zim scraper.
- Linguagem predominante
- Python
- Estrelas
- 31
- Forks
- 31
- Merge médio
- 2d 5h
- PRs com merge (30d)
- 3
Preparar o ambiente
Este projeto não oferece contêiner de desenvolvimento, Dockerfile nem guia de contribuição, então a configuração fica por sua conta: comece pelo README e veja nosso guia da primeira contribuição para os passos gerais.
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de openzim/python-scraperlib
-
HTML rewriting: also rewrite `poster` attributeTalvez já em andamento Um pull request vinculado a esta issue está aberto ou já foi mesclado. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
openzim/python-scraperlib#339 ·
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
openzim/python-scraperlib#292 ·
-
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 68/100
openzim/python-scraperlib#346 ·
-
URL normalisation: do not rewrite consecutive slashes `//` as a single slash `/`Talvez já em andamento @anshuman83-40 assumiu há 7 dias. Aberta
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 45/100
openzim/python-scraperlib#340 ·
-
Add fuzzy rule to rewrite URLs of lesbases.anct.gouv.frTalvez livre de novo @benoit74 assumiu há 50 dias e não há nenhum pull request aberto. Aberta
openzim/python-scraperlib#334 · 1 responsável ·
Todas as issues de openzim/python-scraperlib
Issues semelhantes
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
NousResearch/hermes-agent#136483 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 88/100
Mantenedores costumam responder em até 1 dia
-
[BUG] LazyStackedTensorDictStore zeroes the last byte of a new key set on the last elementTalvez já em andamento @peterdsharpe assumiu hoje. Abertabug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
pytorch/tensordict#2307 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
Mantenedores costumam responder em até 1 dia
-
GrokModel.generate/a_generate pass an OpenAI-style list-of-dicts to xai_sdk.chat.user(), so every call crashes with a protobuf TypeError before any network I/OTalvez já em andamento @Christian-Sidak assumiu hoje. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 70/100
confident-ai/deepeval#3436 · 1 comentário ·
Mantenedores costumam responder em até 1 dia