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

Refactoring the rest of the commands and added the websocket for the assets for speed imporvments #93

Merged
merged 15 commits into from
May 10, 2024

Conversation

Bishoy-at-pieces
Copy link
Collaborator

No description provided.

Copy link
Contributor

@hal-8999-alpha hal-8999-alpha left a 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_api.py Show resolved Hide resolved
src/pieces/assets/assets_command.py Outdated Show resolved Hide resolved

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()
Copy link
Contributor

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/assets/assets_identifiers_ws.py Show resolved Hide resolved
src/pieces/assets/assets_identifiers_ws.py Show resolved Hide resolved
src/pieces/assets/assets_identifiers_ws.py Show resolved Hide resolved
for i, name in enumerate(asset_list, start=1):
print(f"{i}: {name.get('name')}")
if i >= max_assets:
break
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good

src/pieces/commands/search_command.py Show resolved Hide resolved
src/pieces/utils.py Show resolved Hide resolved
@Bishoy-at-pieces
Copy link
Collaborator Author

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

Copy link
Contributor

@caleb-at-pieces caleb-at-pieces left a 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)

src/pieces/assets/assets_api.py Show resolved Hide resolved
src/pieces/assets/assets_api.py Outdated Show resolved Hide resolved
src/pieces/assets/assets_api.py Show resolved Hide resolved
src/pieces/assets/assets_api.py Outdated Show resolved Hide resolved
src/pieces/assets/assets_identifiers_ws.py Show resolved Hide resolved
asyncio.set_event_loop(loop)
loop.run_forever()

async def open_websocket(self):
Copy link
Contributor

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.

Copy link
Collaborator Author

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

Copy link
Contributor

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):
Copy link
Contributor

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'

Copy link
Collaborator Author

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!

src/pieces/utils.py Outdated Show resolved Hide resolved
@Bishoy-at-pieces Bishoy-at-pieces linked an issue May 9, 2024 that may be closed by this pull request
Copy link
Contributor

@hal-8999-alpha hal-8999-alpha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left one comment

src/pieces/utils.py Show resolved Hide resolved
Copy link
Contributor

@caleb-at-pieces caleb-at-pieces left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Copy link
Member

@mark-at-pieces mark-at-pieces left a 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

@Bishoy-at-pieces Bishoy-at-pieces merged commit db0ad14 into pieces-app:main May 10, 2024
@Bishoy-at-pieces Bishoy-at-pieces deleted the improvments branch May 10, 2024 09:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cache assets
4 participants