orgo 0.0.19__tar.gz → 0.0.21__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {orgo-0.0.19 → orgo-0.0.21}/PKG-INFO +1 -1
- {orgo-0.0.19 → orgo-0.0.21}/pyproject.toml +1 -1
- {orgo-0.0.19 → orgo-0.0.21}/src/orgo/api/client.py +4 -2
- {orgo-0.0.19 → orgo-0.0.21}/src/orgo/computer.py +42 -7
- {orgo-0.0.19 → orgo-0.0.21}/src/orgo/project.py +14 -1
- {orgo-0.0.19 → orgo-0.0.21}/src/orgo.egg-info/PKG-INFO +1 -1
- {orgo-0.0.19 → orgo-0.0.21}/README.md +0 -0
- {orgo-0.0.19 → orgo-0.0.21}/setup.cfg +0 -0
- {orgo-0.0.19 → orgo-0.0.21}/src/orgo/__init__.py +0 -0
- {orgo-0.0.19 → orgo-0.0.21}/src/orgo/api/__init__.py +0 -0
- {orgo-0.0.19 → orgo-0.0.21}/src/orgo/prompt.py +0 -0
- {orgo-0.0.19 → orgo-0.0.21}/src/orgo/utils/__init__.py +0 -0
- {orgo-0.0.19 → orgo-0.0.21}/src/orgo/utils/auth.py +0 -0
- {orgo-0.0.19 → orgo-0.0.21}/src/orgo.egg-info/SOURCES.txt +0 -0
- {orgo-0.0.19 → orgo-0.0.21}/src/orgo.egg-info/dependency_links.txt +0 -0
- {orgo-0.0.19 → orgo-0.0.21}/src/orgo.egg-info/requires.txt +0 -0
- {orgo-0.0.19 → orgo-0.0.21}/src/orgo.egg-info/top_level.txt +0 -0
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
# src/orgo/api/client.py
|
|
2
1
|
"""API client for Orgo service"""
|
|
3
2
|
|
|
4
3
|
import requests
|
|
@@ -43,7 +42,10 @@ class ApiClient:
|
|
|
43
42
|
# Computer lifecycle methods
|
|
44
43
|
def create_computer(self, config: Optional[Dict[str, Any]] = None) -> Dict[str, Any]:
|
|
45
44
|
"""Create a new project with desktop instance"""
|
|
46
|
-
|
|
45
|
+
payload = {}
|
|
46
|
+
if config:
|
|
47
|
+
payload["config"] = config
|
|
48
|
+
return self._request("POST", "projects", payload if payload else None)
|
|
47
49
|
|
|
48
50
|
def connect_computer(self, project_id: str) -> Dict[str, Any]:
|
|
49
51
|
return self._request("GET", f"projects/by-name/{project_id}")
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
# src/orgo/computer.py
|
|
2
1
|
"""Computer class for interacting with Orgo virtual environments"""
|
|
3
2
|
import os
|
|
4
3
|
import io
|
|
5
4
|
import base64
|
|
6
5
|
import logging
|
|
7
|
-
from typing import Dict, List, Any, Optional, Callable
|
|
6
|
+
from typing import Dict, List, Any, Optional, Callable, Literal
|
|
8
7
|
from PIL import Image
|
|
9
8
|
import requests
|
|
10
9
|
from requests.exceptions import RequestException
|
|
@@ -16,7 +15,13 @@ from .project import ProjectManager
|
|
|
16
15
|
logger = logging.getLogger(__name__)
|
|
17
16
|
|
|
18
17
|
class Computer:
|
|
19
|
-
def __init__(self,
|
|
18
|
+
def __init__(self,
|
|
19
|
+
project_id: Optional[str] = None,
|
|
20
|
+
api_key: Optional[str] = None,
|
|
21
|
+
config: Optional[Dict[str, Any]] = None,
|
|
22
|
+
base_api_url: Optional[str] = None,
|
|
23
|
+
ram: Optional[Literal[2, 4]] = None,
|
|
24
|
+
cpu: Optional[Literal[2, 4]] = None):
|
|
20
25
|
"""
|
|
21
26
|
Initialize an Orgo virtual computer.
|
|
22
27
|
|
|
@@ -25,6 +30,8 @@ class Computer:
|
|
|
25
30
|
api_key: Orgo API key (defaults to ORGO_API_KEY env var)
|
|
26
31
|
config: Configuration for new computer (optional)
|
|
27
32
|
base_api_url: Custom API URL (optional)
|
|
33
|
+
ram: RAM in GB for new computer (2 or 4) - only used when creating
|
|
34
|
+
cpu: CPU cores for new computer (2 or 4) - only used when creating
|
|
28
35
|
"""
|
|
29
36
|
self.api_key = api_key or os.environ.get("ORGO_API_KEY")
|
|
30
37
|
self.base_api_url = base_api_url
|
|
@@ -38,14 +45,39 @@ class Computer:
|
|
|
38
45
|
try:
|
|
39
46
|
self.project_id = project_id
|
|
40
47
|
self._info = self.api.connect_computer(project_id)
|
|
48
|
+
# Log if ram/cpu were provided but ignored
|
|
49
|
+
if ram is not None or cpu is not None:
|
|
50
|
+
logger.info("Note: ram and cpu parameters are ignored when connecting to existing computer")
|
|
41
51
|
except (RequestException, ValueError) as e:
|
|
42
52
|
logger.warning(f"Could not connect to saved project {project_id}: {e}")
|
|
43
|
-
self._create_new_computer(config)
|
|
53
|
+
self._create_new_computer(config, ram, cpu)
|
|
44
54
|
else:
|
|
45
|
-
self._create_new_computer(config)
|
|
55
|
+
self._create_new_computer(config, ram, cpu)
|
|
46
56
|
|
|
47
|
-
def _create_new_computer(self, config=None
|
|
57
|
+
def _create_new_computer(self, config: Optional[Dict[str, Any]] = None,
|
|
58
|
+
ram: Optional[Literal[2, 4]] = None,
|
|
59
|
+
cpu: Optional[Literal[2, 4]] = None):
|
|
48
60
|
"""Create a new computer instance and save its ID"""
|
|
61
|
+
# Validate ram and cpu values if provided
|
|
62
|
+
if ram is not None and ram not in [2, 4]:
|
|
63
|
+
raise ValueError("ram must be either 2 or 4 GB")
|
|
64
|
+
if cpu is not None and cpu not in [2, 4]:
|
|
65
|
+
raise ValueError("cpu must be either 2 or 4 cores")
|
|
66
|
+
|
|
67
|
+
# Build the config with ram and cpu if provided
|
|
68
|
+
if ram is not None or cpu is not None:
|
|
69
|
+
if config is None:
|
|
70
|
+
config = {}
|
|
71
|
+
else:
|
|
72
|
+
# Make a copy to avoid modifying the original
|
|
73
|
+
config = config.copy()
|
|
74
|
+
|
|
75
|
+
# Add ram and cpu to config
|
|
76
|
+
if ram is not None:
|
|
77
|
+
config['ram'] = ram
|
|
78
|
+
if cpu is not None:
|
|
79
|
+
config['cpu'] = cpu
|
|
80
|
+
|
|
49
81
|
response = self.api.create_computer(config)
|
|
50
82
|
self.project_id = response.get("name")
|
|
51
83
|
self._info = response
|
|
@@ -74,7 +106,10 @@ class Computer:
|
|
|
74
106
|
|
|
75
107
|
def destroy(self) -> Dict[str, Any]:
|
|
76
108
|
"""Terminate and delete the computer instance"""
|
|
77
|
-
|
|
109
|
+
result = self.api.delete_computer(self.project_id)
|
|
110
|
+
# Clear the local project cache after destroying
|
|
111
|
+
ProjectManager.clear_project_cache()
|
|
112
|
+
return result
|
|
78
113
|
|
|
79
114
|
# Navigation methods
|
|
80
115
|
def left_click(self, x: int, y: int) -> Dict[str, Any]:
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
"""Project management for Orgo virtual environments"""
|
|
3
3
|
import os
|
|
4
4
|
import json
|
|
5
|
+
import shutil
|
|
5
6
|
import logging
|
|
6
7
|
from typing import Optional
|
|
7
8
|
|
|
@@ -40,6 +41,18 @@ class ProjectManager:
|
|
|
40
41
|
logger.error(f"Failed to save project ID: {str(e)}")
|
|
41
42
|
raise RuntimeError(f"Failed to save project configuration: {str(e)}") from e
|
|
42
43
|
|
|
44
|
+
@staticmethod
|
|
45
|
+
def clear_project_cache() -> None:
|
|
46
|
+
"""Clear the .orgo folder and all its contents"""
|
|
47
|
+
project_dir = ProjectManager._get_project_dir()
|
|
48
|
+
|
|
49
|
+
if os.path.exists(project_dir):
|
|
50
|
+
try:
|
|
51
|
+
shutil.rmtree(project_dir)
|
|
52
|
+
logger.info(f"Cleared project cache at {project_dir}")
|
|
53
|
+
except (IOError, OSError) as e:
|
|
54
|
+
logger.warning(f"Failed to clear project cache: {str(e)}")
|
|
55
|
+
|
|
43
56
|
@staticmethod
|
|
44
57
|
def _get_project_dir() -> str:
|
|
45
58
|
"""Get the project directory path"""
|
|
@@ -48,4 +61,4 @@ class ProjectManager:
|
|
|
48
61
|
@staticmethod
|
|
49
62
|
def _get_config_path() -> str:
|
|
50
63
|
"""Get the full path to the config file"""
|
|
51
|
-
return os.path.join(ProjectManager._get_project_dir(), "project.json")
|
|
64
|
+
return os.path.join(ProjectManager._get_project_dir(), "project.json")
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|