Skip to content
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
2 changes: 1 addition & 1 deletion w2/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ async def get() -> Dict:
"""

######################################## YOUR CODE HERE ##################################################

return {"status": "ok"}
######################################## YOUR CODE HERE ##################################################


Expand Down
17 changes: 15 additions & 2 deletions w3/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def main() -> List[Dict]:
"""

st = time.time()
n_processes = 3 # you may modify this number - check out multiprocessing.cpu_count() as well
n_processes = 6 # you may modify this number - check out multiprocessing.cpu_count() as well

parser = argparse.ArgumentParser(description="Choose from one of these : [tst|sml|bg]")
parser.add_argument('--type',
Expand All @@ -164,14 +164,27 @@ def main() -> List[Dict]:
batches = batch_files(file_paths=file_paths, n_processes=n_processes)

######################################## YOUR CODE HERE ##################################################
with multiprocessing.Pool(processes=n_processes) as pool:
revenue_data = pool.starmap(run, [(batch, n_process) for n_process, batch in enumerate(batches)])
revenue_data = flatten(lst=revenue_data)

pool.close()
pool.join()
######################################## YOUR CODE HERE ##################################################

en = time.time()
print("Overall time taken : {}".format(en-st))

# should return revenue data
return [{}]
for yearly_data in revenue_data:
with open(os.path.join(output_save_folder, f'{yearly_data["file_name"]}.json'), 'w') as f:
f.write(json.dumps(yearly_data))

plot_sales_data(yearly_revenue=yearly_data['revenue_per_region'], year=yearly_data["file_name"],
plot_save_path=os.path.join(output_save_folder, f'{yearly_data["file_name"]}.png'))

return revenue_data
# return [{}]


if __name__ == '__main__':
Expand Down