fix types and format
This commit is contained in:
parent
91d3237516
commit
b873eaf203
8 changed files with 117 additions and 172 deletions
|
|
@ -1,5 +1,4 @@
|
|||
import asyncio
|
||||
import pathlib
|
||||
from data_access import Listing
|
||||
from tqdm.asyncio import tqdm
|
||||
import multiprocessing
|
||||
|
|
@ -7,25 +6,16 @@ import multiprocessing
|
|||
|
||||
async def detect_floorplan(listing_paths: list[str]):
|
||||
listings = Listing.get_all_listings(listing_paths)
|
||||
cpu_count = multiprocessing.cpu_count() / 4
|
||||
cpu_count = multiprocessing.cpu_count() // 4
|
||||
semaphore = asyncio.Semaphore(cpu_count)
|
||||
|
||||
await tqdm.gather(
|
||||
*[_detect_floorplan_with_semaphore(listing, semaphore) for listing in listings]
|
||||
)
|
||||
await tqdm.gather(*[
|
||||
_detect_floorplan_with_semaphore(listing, semaphore)
|
||||
for listing in listings
|
||||
])
|
||||
|
||||
|
||||
async def _detect_floorplan_with_semaphore(
|
||||
listing: Listing, semaphore: asyncio.Semaphore
|
||||
):
|
||||
async def _detect_floorplan_with_semaphore(listing: Listing,
|
||||
semaphore: asyncio.Semaphore):
|
||||
async with semaphore:
|
||||
return await listing.calculate_sqm_ocr(recalculate=False)
|
||||
|
||||
|
||||
def main():
|
||||
listing_paths = sorted(list(pathlib.Path("data/rs").glob("*/listing.json")))
|
||||
detect_floorplan(listing_paths)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue