Skip to content

Commit 565974e

Browse files
authored
Merge branch 'main' into 1yam-credits-system
2 parents f76de39 + 90b9da0 commit 565974e

File tree

10 files changed

+29
-20
lines changed

10 files changed

+29
-20
lines changed

.github/workflows/build-wheels.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ jobs:
4141
if: startsWith(matrix.os, 'macos-')
4242
run: |
4343
brew update
44-
brew tap cuber/homebrew-libsecp256k1
45-
brew install libsecp256k1
44+
brew install secp256k1
4645
4746
- name: Install required system packages only for Ubuntu Linux
4847
if: startsWith(matrix.os, 'ubuntu-')

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ Using some chains may also require installing `libgmp3-dev`.
2121
### macOs
2222
This project does not support Python 3.12 on macOS. Please use Python 3.11 instead.
2323
```shell
24-
$ brew tap cuber/homebrew-libsecp256k1
25-
$ brew install libsecp256k1
24+
$ brew install secp256k1
2625
```
2726

2827
## Installation

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ dynamic = [ "version" ]
3030
dependencies = [
3131
"aiohttp>=3.8.3",
3232
"aioresponses>=0.7.6",
33-
"aleph-message>=1.0.3",
33+
"aleph-message>=1.0.4",
3434
"aleph-superfluid>=0.3",
3535
"base58==2.1.1", # Needed now as default with _load_account changement
3636
"coincurve; python_version>='3.9'",

src/aleph/sdk/client/http.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ async def get_stored_content(
573573
message, status = await self.get_message(
574574
item_hash=ItemHash(item_hash), with_status=True
575575
)
576-
if status != MessageStatus.PROCESSED:
576+
if status not in [MessageStatus.PROCESSED, MessageStatus.REMOVING]:
577577
resp = f"Invalid message status: {status}"
578578
elif message.type != MessageType.store:
579579
resp = f"Invalid message type: {message.type}"

src/aleph/sdk/client/services/instance.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ async def _fetch(
115115
if isinstance(alloc, InstanceManual):
116116
crn_url = sanitize_url(alloc.crn_url)
117117
else:
118+
if not alloc.allocations:
119+
return str(item_hash), None
118120
crn_url = sanitize_url(alloc.allocations.node.url)
119121

120122
if not crn_url:

src/aleph/sdk/client/services/pricing.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ class Price(BaseModel):
4343
credit: Optional[Decimal] = None
4444

4545

46+
4647
class ComputeUnit(BaseModel):
4748
vcpus: int
4849
memory_mib: int

src/aleph/sdk/client/services/scheduler.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
from typing import TYPE_CHECKING
1+
from typing import TYPE_CHECKING, Optional
22

33
import aiohttp
4+
from aiohttp import ClientResponseError
45
from aleph_message.models import ItemHash
56

67
from aleph.sdk.conf import settings
@@ -39,15 +40,18 @@ async def get_nodes(self) -> SchedulerNodes:
3940

4041
return SchedulerNodes.model_validate(raw)
4142

42-
async def get_allocation(self, vm_hash: ItemHash) -> AllocationItem:
43+
async def get_allocation(self, vm_hash: ItemHash) -> Optional[AllocationItem]:
4344
"""
4445
Fetch allocation information for a given VM hash.
4546
"""
4647
url = f"{sanitize_url(settings.SCHEDULER_URL)}/api/v0/allocation/{vm_hash}"
47-
48-
async with aiohttp.ClientSession() as session:
49-
async with session.get(url) as resp:
50-
resp.raise_for_status()
51-
payload = await resp.json()
52-
53-
return AllocationItem.model_validate(payload)
48+
try:
49+
async with aiohttp.ClientSession() as session:
50+
async with session.get(url) as resp:
51+
resp.raise_for_status()
52+
payload = await resp.json()
53+
return AllocationItem.model_validate(payload)
54+
except ClientResponseError as e:
55+
if e.status == 404: # Allocation can't be find on scheduler
56+
return None
57+
raise e

src/aleph/sdk/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ class Settings(BaseSettings):
8686

8787
DNS_API: ClassVar[str] = "https://api.dns.public.aleph.sh/instances/list"
8888
CRN_URL_UPDATE: ClassVar[str] = "{crn_url}/control/machine/{vm_hash}/update"
89-
CRN_LIST_URL: ClassVar[str] = "https://crns-list.aleph.sh/crns.json"
89+
CRN_LIST_URL: str = "https://crns-list.aleph.sh/crns.json"
9090
CRN_VERSION_URL: ClassVar[str] = (
9191
"https://api.github.com/repos/aleph-im/aleph-vm/releases/latest"
9292
)

src/aleph/sdk/types.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,9 @@ class AllocationItem(BaseModel):
192192

193193
class InstanceWithScheduler(BaseModel):
194194
source: Literal["scheduler"]
195-
allocations: AllocationItem # Case Scheduler
195+
allocations: Optional[
196+
AllocationItem
197+
] # Case Scheduler (None == allocation can't be find on scheduler)
196198

197199

198200
class InstanceManual(BaseModel):

tests/unit/services/pricing_aggregate.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"payg": "0.011",
1414
"holding": "200",
1515
"credit": "0.011"
16-
}
16+
},
1717
},
1818
"tiers": [
1919
{
@@ -66,7 +66,7 @@
6666
"payg": "0.055",
6767
"holding": "1000",
6868
"credit": "0.055"
69-
}
69+
},
7070
},
7171
"tiers": [
7272
{
@@ -119,7 +119,7 @@
119119
"payg": "0.055",
120120
"holding": "1000",
121121
"credit": "0.055"
122-
}
122+
},
123123
},
124124
"tiers": [
125125
{
@@ -162,6 +162,7 @@
162162
"compute_unit": {
163163
"payg": "0.56",
164164
"credit": "0.56"
165+
"payg": "0.000000977"
165166
}
166167
},
167168
"tiers": [
@@ -238,6 +239,7 @@
238239
"compute_unit": {
239240
"payg": "0.28",
240241
"credit": "0.28"
242+
"payg": "0.000000977"
241243
}
242244
},
243245
"tiers": [

0 commit comments

Comments
 (0)