Skip to content

Commit 0738dd7

Browse files
author
Alan Christie
committed
fix: README typos and better 'coins' (storage contribuition now separate)
1 parent 3dce9f5 commit 0738dd7

File tree

2 files changed

+33
-24
lines changed

2 files changed

+33
-24
lines changed

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ set of examples so that users can create their own utilities.
1313
> Most tools need to be executed by a user with admin privileges.
1414
1515
## Usage
16-
The tools utilise the Pyhon client's `Environment` module, which expects
16+
The tools utilise the Python client's `Environment` module, which expects
1717
you to create an `Envrionments` file - a YAML file that defines the
1818
variables used to connect to the corresponding installation. The environments
19-
file (typically `~/.squonk2/environmemnts`) allows you to creat variables
19+
file (typically `~/.squonk2/environmemnts`) allows you to create variables
2020
for multiple installations identified by name.
2121

2222
See the **Environment module** section of the [Squonk2 Python Client].
@@ -43,11 +43,14 @@ display the tool's help.
4343
You should find the following tools in this repository: -
4444

4545
- `coins`
46+
- `create-organisations-and-units`
4647
- `delete-all-instances`
4748
- `delete-old-instances`
4849
- `delete-test-projects`
50+
- `job-exchange-rate`
4951
- `list-environments`
5052
- `load-er`
53+
- `load-job-manifests`
5154
- `save-er`
5255

5356
---

tools/coins.py

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from decimal import Decimal
77
import sys
88
from typing import Any, Dict, Optional
9+
from attr import dataclass
910
import urllib3
1011

1112
from rich.pretty import pprint
@@ -16,8 +17,12 @@
1617

1718
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
1819

19-
AdjustedCoins: namedtuple = namedtuple("AdjustedCoins",
20-
["coins", "fc", "ac", "aac"])
20+
@dataclass
21+
class AdjustedCoins:
22+
coins: Decimal
23+
fc: Decimal
24+
ac: Decimal
25+
aac: Decimal
2126

2227

2328
def main(c_args: argparse.Namespace) -> None:
@@ -37,7 +42,7 @@ def main(c_args: argparse.Namespace) -> None:
3742
password=env.admin_password,
3843
)
3944
if not token:
40-
console.log(f"[bold red]ERROR[/bold red] Failed to get token")
45+
console.log("[bold red]ERROR[/bold red] Failed to get token")
4146
sys.exit(1)
4247

4348
# Get the product details.
@@ -131,27 +136,28 @@ def main(c_args: argparse.Namespace) -> None:
131136
"Coins (Adjusted)": f"{ac.fc} + {ac.aac} = {ac.coins}",
132137
}
133138

134-
additional_coins: Decimal = total_uncommitted_processing_coins + burn_rate * remaining_days
139+
burn_rate_contribution: Decimal = burn_rate * remaining_days
140+
additional_coins: Decimal = total_uncommitted_processing_coins + burn_rate_contribution
135141
predicted_total_coins: Decimal = total_coins
136142
zero: Decimal = Decimal()
137-
if remaining_days > 0:
138-
if burn_rate > zero:
139-
140-
predicted_total_coins += additional_coins
141-
p_ac: AdjustedCoins = _calculate_adjusted_coins(
142-
predicted_total_coins,
143-
allowance,
144-
allowance_multiplier)
145-
146-
invoice["Prediction"] = {
147-
"Coins (Burn Rate)": str(burn_rate),
148-
"Coins (Additional Spend)": f"{total_uncommitted_processing_coins} + {remaining_days} x {burn_rate} = {additional_coins}",
149-
"Coins (Total Raw)": f"{total_coins} + {additional_coins} = {predicted_total_coins}",
150-
"Coins (Penalty Free)": str(p_ac.fc),
151-
"Coins (In Allowance Band)": str(p_ac.ac),
152-
"Coins (Allowance Charge)": f"{p_ac.ac} x {allowance_multiplier} = {p_ac.aac}",
153-
"Coins (Adjusted)": f"{p_ac.fc} + {p_ac.aac} = {p_ac.coins}",
154-
}
143+
if remaining_days > 0 and burn_rate > zero:
144+
145+
predicted_total_coins += additional_coins
146+
p_ac: AdjustedCoins = _calculate_adjusted_coins(
147+
predicted_total_coins,
148+
allowance,
149+
allowance_multiplier)
150+
151+
invoice["Prediction"] = {
152+
"Coins (Burn Rate)": str(burn_rate),
153+
"Coins (Burn Rate Contribution)": f"{remaining_days} x {burn_rate} = {burn_rate_contribution}",
154+
"Coins (Additional Spend)": f"{total_uncommitted_processing_coins} + {burn_rate_contribution} = {additional_coins}",
155+
"Coins (Total Raw)": f"{total_coins} + {additional_coins} = {predicted_total_coins}",
156+
"Coins (Penalty Free)": str(p_ac.fc),
157+
"Coins (In Allowance Band)": str(p_ac.ac),
158+
"Coins (Allowance Charge)": f"{p_ac.ac} x {allowance_multiplier} = {p_ac.aac}",
159+
"Coins (Adjusted)": f"{p_ac.fc} + {p_ac.aac} = {p_ac.coins}",
160+
}
155161

156162
# Now just pre-tty-print the invoice
157163
pprint(invoice)

0 commit comments

Comments
 (0)