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

Reduce instance PAYG balance to half #310

Merged
merged 1 commit into from
Dec 2, 2024
Merged
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
11 changes: 7 additions & 4 deletions src/aleph_client/commands/instance/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@
logger = logging.getLogger(__name__)
app = AsyncTyper(no_args_is_help=True)

# TODO: This should be put on the API to get always from there
FLOW_INSTANCE_PRICE_PER_SECOND = Decimal(0.0000155) # 0.055/h


@app.command()
async def create(
Expand Down Expand Up @@ -201,7 +204,7 @@ async def create(
account.switch_chain(payment_chain)
if account.superfluid_connector and hasattr(account.superfluid_connector, "can_start_flow"):
try: # Quick check with theoretical min price
account.superfluid_connector.can_start_flow(Decimal(0.000031)) # 0.11/h
account.superfluid_connector.can_start_flow(FLOW_INSTANCE_PRICE_PER_SECOND) # 0.055/h
except Exception as e:
echo(e)
raise typer.Exit(code=1)
Expand Down Expand Up @@ -286,7 +289,7 @@ async def create(

name = name or validated_prompt("Instance name", lambda x: len(x) < 65)
rootfs_size = rootfs_size or validated_int_prompt(
"Disk size in MiB", default=settings.DEFAULT_ROOTFS_SIZE, min_value=10_240, max_value=102_400
"Disk size in MiB", default=settings.DEFAULT_ROOTFS_SIZE, min_value=10_240, max_value=542_288
)
vcpus = vcpus or validated_int_prompt(
"Number of virtual cpus to allocate", default=settings.DEFAULT_VM_VCPUS, min_value=1, max_value=4
Expand All @@ -295,7 +298,7 @@ async def create(
"Maximum memory allocation on vm in MiB",
default=settings.DEFAULT_INSTANCE_MEMORY,
min_value=2_048,
max_value=8_192,
max_value=12_288,
)

volumes = []
Expand Down Expand Up @@ -429,7 +432,7 @@ async def create(
required_tokens = ceil(Decimal(price.required_tokens) * ceil_factor) / ceil_factor
if isinstance(account, ETHAccount) and account.superfluid_connector:
try: # Double check with effective price
account.superfluid_connector.can_start_flow(Decimal(0.000031)) # Min for 0.11/h
account.superfluid_connector.can_start_flow(FLOW_INSTANCE_PRICE_PER_SECOND) # Min for 0.11/h
except Exception as e:
echo(e)
raise typer.Exit(code=1)
Expand Down
Loading