wlmwng / inca Goto Github PK
View Code? Open in Web Editor NEWThis version of INCA helps manage data collection and data processing for the us-right-media project.
This version of INCA helps manage data collection and data processing for the us-right-media project.
Do you know what the correct way is to call INCA's processors with the batch
action? I'm planning to use multiple processors and this option will be helpful since it'll be more efficient for sending HTTP requests to Elasticsearch (vs. run
which sends a request per doc). I'm getting a name 'bulksize' is not defined
error though when I pass bulksize=100
as an argument to the processor.
try:
rules_fox = [
{"regexp": "\\n[A-Z0-9 :,\\'!@\$\(\)\-\.\?\:\;]+(?:\\n|$)", "replace_with": ""},
{
"regexp": "Get all the latest news on coronavirus and more delivered daily to your inbox\. Sign up here",
"replace_with": "",
},
]
# generator
docs_regexp = myinca.processing.multireplace(
docs_or_query="foxnews",
field="article_maintext",
rules=rules_fox,
save=True,
new_key="article_maintext_0",
action="batch",
batchsize=100,
)
for doc in docs_regexp:
# runs process on doc
# doesn't yield updated doc since it saves to db
pass
except Exception as e:
LOGGER.warning(e)
2021-11-02 07:42:55,030 - [INFO] - INCA - (processor_class.py)._doctype_query_or_list(228) - assuming documents of given type should be processed
2021-11-02 07:42:55,030 - [INFO] - INCA - (processor_class.py)._doctype_query_or_list(234) - force=False, ignoring documents where the result key exists (and has non-NULL value)
2021-11-02 07:42:55,030 - [WARNING] - main - (1275500693.py).<module>(27) - name 'bulksize' is not defined
processor_class.py
, but it'd be helpful if you could help me understand:bulksize=100
to show up as a kwarg, andtarget_func
comes from def runwrap(
self,
docs_or_query,
field,
new_key=None,
save=False,
force=False,
action="run",
*args,
**kwargs
):
...
elif action == "batch":
for num, batch in enumerate(_batcher(documents, batchsize=bulksize)):
core.database.bulk_upsert().run(
documents=[
target_func.run(
document=doc, field=field, force=force, *args, **kwargs
)
for doc in batch
]
)
now = datetime.datetime.now()
logger.info("processed batch {num} {now}".format(**locals()))
yield batch
The fork is WIP at the moment, but it should be added to requirements.txt when it's ready.
https://matiascodesal.com/blog/how-use-git-repository-pip-dependency/
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.