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
Merged
Show file tree
Hide file tree
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
272 changes: 49 additions & 223 deletions poetry.lock

Large diffs are not rendered by default.

8 changes: 0 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,7 @@

[tool.poetry.dependencies]
python = ">=3.9,<3.13"
beautifulsoup4 = "4.12.3"
aenum = "3.1.15"
certifi = "2023.11.17"
charset-normalizer = "3.3.2"
pydantic = "1.10.13"
pyperclip = ">=1.8.2"
requests = ">=2.31.0"
typing-extensions = "4.9.0"
urllib3 = ">=2.2.0,<3.0.0"
websocket-client = "1.7.0"
pieces_os_client = "1.2.7"
prompt-toolkit = "^3.0.43"
Expand Down
Empty file removed src/pieces/api/__init__.py
Empty file.
32 changes: 0 additions & 32 deletions src/pieces/api/api_functions.py

This file was deleted.

196 changes: 0 additions & 196 deletions src/pieces/api/assets.py

This file was deleted.

28 changes: 17 additions & 11 deletions src/pieces/app.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
import sys
from pieces_os_client.api.os_api import OSApi


from pieces.gui import print_help
import pieces_os_client as pos_client
from pieces.api.api_functions import sign_out
from pieces.pieces_argparser import PiecesArgparser
from pieces.commands import *
from pieces.settings import Settings
import sys


from pieces.commands import *
from pieces.autocommit import *
from pieces.copilot import *
from pieces.assets import *

class PiecesCLI:
def __init__(self):
Expand All @@ -19,25 +25,25 @@ def add_subparsers(self):
list_parser = self.command_parser.add_parser('list', help='List the assets or apps or models')
list_parser.add_argument('type', nargs='?', type=str ,default="assets", help='type of the list',choices=["assets","apps","models"])
list_parser.add_argument('max_assets', nargs='?', type=int ,default=10, help='Max number of assets')
list_parser.set_defaults(func=list_command)
list_parser.set_defaults(func=ListCommand.list_command)


# Subparser for the 'open' command
open_parser = self.command_parser.add_parser('open', help='Open an asset')
open_parser.add_argument('ITEM_INDEX', type=int, nargs='?', default=None, help='Index of the item to open (optional)')
open_parser.set_defaults(func=open_asset)
open_parser.set_defaults(func=AssetsCommands.open_asset)

# Subparser for the 'save' command
save_parser = self.command_parser.add_parser('save', help='Updates the current asset')
save_parser.set_defaults(func=update_asset_value)
save_parser.set_defaults(func=AssetsCommands.update_asset)

# Subparser for the 'delete' command
delete_parser = self.command_parser.add_parser('delete', help='Delete the current asset')
delete_parser.set_defaults(func=delete_asset)
delete_parser.set_defaults(func=AssetsCommands.delete_asset)

# Subparser for the 'create' command
create_parser = self.command_parser.add_parser('create', help='Create a new asset')
create_parser.set_defaults(func=create_asset)
create_parser.set_defaults(func=AssetsCommands.create_asset)

# Subparser for the 'run' command
run_parser = self.command_parser.add_parser('run', help='Runs CLI in a loop')
Expand All @@ -47,7 +53,7 @@ def add_subparsers(self):
edit_parser = self.command_parser.add_parser('edit', help='Edit an existing asset')
edit_parser.add_argument('--name',"-n",dest='name', help='New name for the asset', required=False)
edit_parser.add_argument('--classification',"-c",dest='classification', help='reclassify the asset', required=False)
edit_parser.set_defaults(func=edit_asset)
edit_parser.set_defaults(func=AssetsCommands.edit_asset)

# Subparser for the 'ask' command
ask_parser = self.command_parser.add_parser('ask', help='Ask a question to a model')
Expand Down Expand Up @@ -79,7 +85,7 @@ def add_subparsers(self):

# Subparser for the 'login' command
login_parser = self.command_parser.add_parser('login', help='Login to pieces os')
login_parser.set_defaults(func=lambda **kwargs: print(f'Logged in as {pos_client.OSApi(Settings.api_client).sign_into_os().name}'))
login_parser.set_defaults(func=lambda **kwargs: print(f'Logged in as {OSApi(Settings.api_client).sign_into_os().name}'))

# Subparser for the 'logout' command
logout_parser = self.command_parser.add_parser('logout', help='Logout from pieces os')
Expand Down
2 changes: 2 additions & 0 deletions src/pieces/assets/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from .assets_api import AssetsCommandsApi
from .assets_command import AssetsCommands,check_asset_selected,check_assets_existence
Loading