Skip to content

Commit

Permalink
[CU-86b2nugu4] Remove platform commands
Browse files Browse the repository at this point in the history
  • Loading branch information
mpanik committed Nov 8, 2024
1 parent c1df0b6 commit c5fdc41
Show file tree
Hide file tree
Showing 10 changed files with 10 additions and 376 deletions.
1 change: 0 additions & 1 deletion dnastack/alpha/app/explorer.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from typing import Optional
import json
from typing import Optional
from urllib.parse import urljoin
Expand Down
7 changes: 0 additions & 7 deletions dnastack/cli/commands/workbench/samples/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@ def files_command_group():
help='The ID of the sample for which the files will be listed.',
required=True,
),
ArgumentSpec(
name='platform',
arg_names=['--platform'],
help='Filter the files to show only those that originated from a specific platform.',
),
ArgumentSpec(
name='storage',
arg_names=['--storage'],
Expand Down Expand Up @@ -70,7 +65,6 @@ def list_sample_files(
page: Optional[int],
page_size: Optional[int],
sort: Optional[str],
platform: Optional[str],
storage: Optional[str],
instrument_id: Optional[str],
platform_type: Optional[PlatformType],
Expand All @@ -85,7 +79,6 @@ def list_sample_files(
page_size=page_size,
sort=sort,
storage_id=storage,
platform_id=platform,
platform_type=platform_type,
instrument_id=instrument_id,
search=search
Expand Down
2 changes: 0 additions & 2 deletions dnastack/cli/commands/workbench/storage/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from dnastack.cli.commands.workbench.storage.add import add_storage_command_group
from dnastack.cli.commands.workbench.storage.commands import init_storage_commands
from dnastack.cli.commands.workbench.storage.platforms import storage_platforms_command_group
from dnastack.cli.commands.workbench.storage.update import update_storage_command_group
from dnastack.cli.core.group import formatted_group

Expand All @@ -15,4 +14,3 @@ def storage_command_group():
# Register sub-groups
storage_command_group.add_command(add_storage_command_group)
storage_command_group.add_command(update_storage_command_group)
storage_command_group.add_command(storage_platforms_command_group)
202 changes: 0 additions & 202 deletions dnastack/cli/commands/workbench/storage/platforms.py

This file was deleted.

2 changes: 0 additions & 2 deletions dnastack/client/workbench/samples/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ class SampleFile(BaseModel):
sample_id: str
path: str
storage_account_id: Optional[str]
platform_id: Optional[str]
platform_type: Optional[PlatformType]
instrument_id: Optional[str]
region: Optional[str]
Expand All @@ -38,7 +37,6 @@ def items(self) -> List[Any]:


class SampleFilesListOptions(BaseListOptions):
platform_id: Optional[str]
storage_id: Optional[str]
platform_type: Optional[PlatformType]
instrument_id: Optional[str]
Expand Down
56 changes: 1 addition & 55 deletions dnastack/client/workbench/storage/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
from dnastack.client.result_iterator import ResultIterator
from dnastack.client.service_registry.models import ServiceType
from dnastack.client.workbench.base_client import BaseWorkbenchClient, WorkbenchResultLoader
from dnastack.client.workbench.storage.models import StorageAccount, StorageListOptions, StorageListResponse, \
Platform, PlatformListOptions, PlatformListResponse
from dnastack.client.workbench.storage.models import StorageAccount, StorageListOptions, StorageListResponse
from dnastack.common.tracing import Span
from dnastack.http.session import HttpSession

Expand All @@ -31,26 +30,6 @@ def extract_api_response(self, response_body: dict) -> StorageListResponse:
return StorageListResponse(**response_body)


class PlatformListResultLoader(WorkbenchResultLoader):
def __init__(self,
service_url: str,
http_session: HttpSession,
trace: Optional[Span],
list_options: Optional[PlatformListOptions] = None,
max_results: int = None):
super().__init__(service_url=service_url,
http_session=http_session,
list_options=list_options,
max_results=max_results,
trace=trace)

def get_new_list_options(self) -> PlatformListOptions:
return PlatformListOptions()

def extract_api_response(self, response_body: dict) -> PlatformListResponse:
return PlatformListResponse(**response_body)


class StorageClient(BaseWorkbenchClient):
@staticmethod
def get_adapter_type() -> str:
Expand Down Expand Up @@ -110,36 +89,3 @@ def list_storage_accounts(self, list_options: Optional[StorageListOptions], max_
list_options=list_options,
trace=None,
max_results=max_results))

def add_platform(self, platform: Platform) -> Platform:
"""Create a new platform."""
with self.create_http_session() as session:
response = session.post(
urljoin(self.endpoint.url, f'{self.namespace}/storage/{platform.storage_account_id}/platforms'),
json=platform.dict()
)
return Platform(**response.json())

def delete_platform(self, platform_id: str, storage_account_id: str) -> None:
"""Delete a platform."""
with self.create_http_session() as session:
session.delete(urljoin(self.endpoint.url, f'{self.namespace}/storage/{storage_account_id}/platforms/{platform_id}'))
return None

def get_platform(self, platform_id: str, storage_account_id: str) -> Platform:
"""Get a platform of storage account by its ID."""
with self.create_http_session() as session:
response = session.get(urljoin(self.endpoint.url, f'{self.namespace}/storage/{storage_account_id}/platforms/{platform_id}'))
return Platform(**response.json())

def list_platforms(self, list_options: Optional[PlatformListOptions], max_results: int) -> Iterator[Platform]:
"""List platforms."""
url = f'{self.namespace}/storage/{list_options.storage_account_id}/platforms' \
if list_options.storage_account_id \
else f'{self.namespace}/storage/platforms'
return ResultIterator(PlatformListResultLoader(
service_url=urljoin(self.endpoint.url, url),
http_session=self.create_http_session(),
list_options=list_options,
trace=None,
max_results=max_results))
22 changes: 0 additions & 22 deletions dnastack/client/workbench/storage/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,25 +63,3 @@ class StorageListResponse(PaginatedResource):
def items(self) -> List[Any]:
return self.accounts


class Platform(BaseModel):
id: Optional[str]
namespace: Optional[str]
storage_account_id: Optional[str]
name: Optional[str]
path: Optional[str]
type: Optional[PlatformType]
created_at: Optional[str]
last_updated_at: Optional[str]


class PlatformListOptions(BaseListOptions):
storage_account_id: Optional[str]
sort: Optional[str]


class PlatformListResponse(PaginatedResource):
platforms: List[Platform]

def items(self) -> List[Any]:
return self.platforms
5 changes: 3 additions & 2 deletions dnastack/common/console.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import sys
from imagination.decorator import service
from threading import Lock

from imagination.decorator import service


@service.registered()
class Console:
Expand All @@ -20,4 +21,4 @@ def print(self, content, end='\n', to_stderr = False):
sys.stderr.flush()
else:
print(content, end=end)
sys.stdout.flush()
sys.stdout.flush()
Loading

0 comments on commit c5fdc41

Please sign in to comment.