Skip to content

Commit

Permalink
Fix issue with other runtime info not being indexed
Browse files Browse the repository at this point in the history
  • Loading branch information
cryptobench committed Feb 25, 2024
1 parent 7a06d75 commit 4cc544a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 19 deletions.
22 changes: 9 additions & 13 deletions stats-backend/api2/scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ def update_providers_info(node_props):
offerobj, offercreated = Offer.objects.get_or_create(
provider=obj, runtime=data["golem.runtime.name"]
)
vectors = {}
if data["golem.runtime.name"] == "vm":
vectors = {}
for key, value in enumerate(data["golem.com.usage.vector"]):
vectors[value] = key
monthly_pricing = (
Expand All @@ -64,9 +64,7 @@ def update_providers_info(node_props):
offerobj.monthly_price_glm = monthly_pricing
offerobj.monthly_price_usd = monthly_pricing * glm_usd_value.current_price
offerobj.hourly_price_glm = monthly_pricing / hours_in_current_month
offerobj.hourly_price_usd = (
offerobj.monthly_price_usd / hours_in_current_month
)
offerobj.hourly_price_usd = offerobj.monthly_price_usd / hours_in_current_month
vcpu_needed = data.get("golem.inf.cpu.threads", 0)
memory_needed = data.get("golem.inf.mem.gib", 0.0)
closest_ec2 = (
Expand Down Expand Up @@ -100,17 +98,15 @@ def update_providers_info(node_props):
# Update Offer object fields for cheaper comparison
offerobj.cheaper_than = closest_ec2 if offer_is_cheaper else None
offerobj.times_cheaper = (
float(ec2_monthly_price) / offer_price_usd
if offer_is_cheaper
else None
float(ec2_monthly_price) / offer_price_usd if offer_is_cheaper else None
)

else:
# print(
# "No matching EC2Instance found or monthly pricing is not available."
# )
offerobj.is_overpriced = False
offerobj.overpriced_compared_to = None
else:
# print(
# "No matching EC2Instance found or monthly pricing is not available."
# )
offerobj.is_overpriced = False
offerobj.overpriced_compared_to = None

offerobj.properties = data
offerobj.save()
Expand Down
12 changes: 6 additions & 6 deletions stats-backend/core/celery.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ def setup_periodic_tasks(sender, **kwargs):
compare_ec2_and_golem,
)

sender.add_periodic_task(
30.0,
offer_scraper.s(),
queue="yagna",
options={"queue": "yagna", "routing_key": "yagna"},
)
# sender.add_periodic_task(
# 30.0,
# offer_scraper.s(),
# queue="yagna",
# options={"queue": "yagna", "routing_key": "yagna"},
# )
sender.add_periodic_task(
crontab(hour="*/24"),
store_ec2_info.s(),
Expand Down

0 comments on commit 4cc544a

Please sign in to comment.