-
Notifications
You must be signed in to change notification settings - Fork 15
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
207 adding creation of an instance with payg #208
Conversation
Antonyjin
commented
May 22, 2024
•
edited
Loading
edited
- Use of a constant instead of None to indicate the end of processing
- Use a structrure type instead of a dictionary
- Specify caught exceptions
- Put the MachineUsage -> array list transformation into a function
- Pass Structure to the queue and specify its type as an annotation
- Run mypy and ruff and fix problems encountered
- Move instance-related code to another file (refactor page in general)
- Add unit tests + Learn more about TDD: Test-Driven Development
- Add docstrings
- Check presence of type annotations (mypy can help)
- Change the hardcoded string about version
…om the CLI The user don't have the possibility to create an instance using a CRN with PAYG by passing by the CLI Solution: Adding and ask if the user wants to create a PAYG instance. For now, we only ask if the user wants to create a PAYG instance. If yes, it shows a list of every compatible CRN. It takes some time, about 5 minutes to fetch the data. To do: Show the available ressources. Create the instance with PAYG Modify the instance message
While fetching compatible nodes, there is only a loading bar with a pourcentage. And then only at the end it displays the whole tab with every CRN hashes Solution: Display the tab within the fetch of nodes That way user have a visibiity on the fetch process and it's more visual
The hash given for the payg crn was not checked. Solution: Adding an error handling to check if the hash given by the user is a correct and compatible hash from the fetched list
Tab didn't show enough info about the CRN such as the console: (RAM, HDD, Version ...) Solution: Replace old info by these ones
Code did not checked if the payment was none in the case where it's not PAYG instance Solution: Default setting payment as None to pass in the message if it's not PAYG
Getting information and dislaying a live tab took too long Solution: Adding timeout and queue system for gain some time on the execution.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice start.
I added comments to improve the structure of the code.
Can you add type annotations and check the output of mypy
and ruff check
on the new code ?
@@ -178,6 +199,9 @@ def validate_ssh_pubkey_file(file: Union[str, Path]) -> Path: | |||
async with AuthenticatedAlephHttpClient( | |||
account=account, api_server=sdk_settings.API_HOST | |||
) as client: | |||
payment = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a typing annotation ?
Originally the fetch of the version is about parsing an HTML text which was not the best thing to do Solution: use the last server header in the response instead to get the version of the CRN
I checked the request only with the status 200 which is not enough Solution: Using raise_for_status()
Some varibles don't have types Solution: Adding typing notation to them
Some of the request returned an error which wasn't checked This result to the end of execution of the script Solution: Adding a check about Exception and add the possibility to debug inside the logger
To stop it, we add 'None' at the end of the queue. But this could be more specific and clear in the code Solution: Creating a local variable which clearly tells that it is the end of the queuing process
Basically, we added a list of str inside the queue and then adding them inside the Live tab but this is unclear and could cause some misunderstanding from the users Solution: Creating a structure and pass this inside the queue The structure contains a field for MachineUsage and more for the required string such as the name, version, address, etc ... This permits to exactly know what is inside the queue and retrieve more easily the different information about it
Solution: Checking every error raised by my py and fix them
Solution: Fix them one by one
This documentation inside the functions is needed to a better understanding of how they works Solution: Adding docstring to each function
If the fetch of the version wasn't found (Timeout, connectionError, etc ...) There was a hardcoded string that replaced the version field. But this wasn't the best option. Solution: Return Optionnal[str] instead for being able to return a None value
Changed import paths to use explicit imports from specific modules within aleph_message.models, fixing incorrect or missing import paths. Solution: Specify the whole path for imports that wasn't well written
Changed import paths to use explicit imports from specific modules within aleph_message.models, fixing incorrect or missing import paths. Solution: Specify the whole path for imports that wasn't well written
Solution: Changed the way hypervisor is selected to ensure type safety and consistency with HypervisorType enum. Previously, the hypervisor selection was done using Prompt.ask which returns a string. Now, the selected string is used to fetch the corresponding HypervisorType from the HypervisorType enum dictionary.
This could be simplified by calling get_message() function Solution: Instead of retrieving all messages and then selecting the program message from the list, this commit refactors the `unpersist` function to directly fetch the program message using the `get_message` method. This change simplifies the logic by ensuring that only the relevant program message is retrieved and processed.
Replaced with #216 |