-
Notifications
You must be signed in to change notification settings - Fork 19
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
Refactoring the rest of the commands and added the websocket for the assets for speed imporvments #93
Refactoring the rest of the commands and added the websocket for the assets for speed imporvments #93
Conversation
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.
Great stuff! Really happy you're reporting a major speed increase. Most of the comments I have in here are nit picky and some are prob more for future PRs. The only major thing I'd say is that we're on opposite sides of the spectrum with error handling. I know you want to minimize try catch blocks. @mark-at-pieces should prob make a judgement call on if we should have more error handling or keep it minimalistic.
src/pieces/assets/assets_command.py
Outdated
|
||
if not name and not classification: # If no name or no classification is provided | ||
# Ask the user for a new name | ||
name = input("Enter the new name for the asset[leave blank to keep the same]: ").strip() |
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.
Since we're refactoring user inputs should probably live in a UI component
src/pieces/commands/list_command.py
Outdated
for i, name in enumerate(asset_list, start=1): | ||
print(f"{i}: {name.get('name')}") | ||
if i >= max_assets: | ||
break |
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.
Good
I am sure that there will not be any errors to catch in the api calls even if it will be handled using the argparser in the pieces_argparser.py file |
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.
looking very solid I just noticed a couple places that might lead to some issues in the future also some minor improvements (that are more of a suggestion, and can probably live as a github issue instead of needing to add them in this pull request)
asyncio.set_event_loop(loop) | ||
loop.run_forever() | ||
|
||
async def open_websocket(self): |
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.
since opening a websocket takes a certain amount of time, this method can technically get called many times on startup, leading to multiple websocket connections being opened. One way that could help prevent this is by making these connection management functions private to its class.
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.
Why the startup function will be called multiple times and even if we have a check where it make sure that it is not connected
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.
Why the startup function will be called multiple times and even if we have a check where it make sure that it is not connected
We do have a check to see it's connected however this boolean will not flip until the websocket has fully connected ( which takes some time ).
Fixing this will prevent an issue from happening with this in the future.
from pieces.settings import Settings | ||
|
||
# Used to create a valid file name when opening to "Opened Snippets" | ||
def sanitize_filename(name): |
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.
this strategy is probably okay however a better one might be to use url encoding for this.
For example, instead of encoding ' ' as '_' we can encode it as '%20'
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.
This is the name of the file!
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.
Left one comment
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.
lgtm
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.
took a loot at the broad brush strokes, looks like some good refactoring, for the rest of the code I will lean on Calebs rev, Good stuff here
No description provided.