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

start date #55

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions snippets/pyaloha/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import os
import argparse

from pyaloha.protocol.base import str2date
from pyaloha.protocol import WorkerResults, str2date
Copy link
Author

Choose a reason for hiding this comment

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

изменение уже было

from pyaloha.settings import DEFAULT_WORKER_NUM, DEFAULT_ALOHA_DATA_DIR
from pyaloha.worker import invoke_cmd_worker, load_plugin, setup_logs

Expand Down Expand Up @@ -103,7 +103,7 @@ def aggregate_raw_data(
]

tasks = [
(plugin_dir, plugin, fpath, events_limit)
(plugin_dir, plugin, fpath, events_limit, start_date)
for fpath in files
]

Expand Down Expand Up @@ -135,7 +135,7 @@ def aggregate_raw_data(
)
for file_name, results in engine(invoke_cmd_worker, batch_tasks):
try:
results = aggregator.loads_results(results)
Copy link
Author

Choose a reason for hiding this comment

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

изменение уже было

results = WorkerResults.loads_object(results)
logger.info(
'Aggregator: task %s is being aggregated' % file_name
)
Expand Down
12 changes: 8 additions & 4 deletions snippets/pyaloha/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ def invoke_cmd_worker(item):
try:
pid = multiprocessing.current_process().pid

plugin_dir, plugin, filepath, events_limit = item
plugin_dir, plugin, filepath, events_limit, start_date = item
worker_fpath = os.path.abspath(__file__)
cmd = 'gzip -d -c %s | python2.7 %s %s %s %s' % (
filepath, worker_fpath, plugin_dir, plugin, events_limit
cmd = 'gzip -d -c %s | python2.7 %s %s %s %s %s' % (
filepath, worker_fpath, plugin_dir, plugin, events_limit, start_date
)
logger.info(
'%d: Starting job: %s', pid, cmd
Expand Down Expand Up @@ -71,6 +71,10 @@ def parse_args():
help='Read only first N events. If not specified, will read all events',
default=0
)
parser.add_argument(
'start_date',
help='First date of tracking range',
)
return parser.parse_args()


Expand All @@ -82,7 +86,7 @@ def worker():
try:
processor = load_plugin(
args.plugin, plugin_dir=args.plugin_dir
).DataStreamWorker()
).DataStreamWorker(start_date=args.start_date)
iterate_events(processor, events_limit=args.events_limit)
processor.pre_output()
sys.stdout.write(processor.dumps_results() + '\n')
Expand Down