Skip to content

Commit af0b2d8

Browse files
committed
Add docstrings
1 parent c9cc306 commit af0b2d8

File tree

2 files changed

+71
-28
lines changed

2 files changed

+71
-28
lines changed

gradient/api_sdk/clients/machines_client.py

Lines changed: 70 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,13 @@ def create(
7676
return handle
7777

7878
def get(self, id):
79+
"""Get machine instance
80+
81+
:param str id: ID of a machine [required]
82+
83+
:return: Machine instance
84+
:rtype: models.Machine
85+
"""
7986
repository = repositories.GetMachine(api_key=self.api_key, logger=self.logger)
8087
instance = repository.get(id=id)
8188
return instance
@@ -95,14 +102,29 @@ def is_available(self, machine_type, region):
95102
return handle
96103

97104
def restart(self, id):
105+
"""Restart machine
106+
107+
:param str id: ID of a machine [required]
108+
"""
109+
98110
repository = repositories.RestartMachine(api_key=self.api_key, logger=self.logger)
99111
repository.restart(id)
100112

101113
def start(self, id):
114+
"""Start machine
115+
116+
:param str id: ID of a machine [required]
117+
"""
118+
102119
repository = repositories.StartMachine(api_key=self.api_key, logger=self.logger)
103120
repository.start(id)
104121

105122
def stop(self, id):
123+
"""Stop machine
124+
125+
:param str id: ID of a machine [required]
126+
"""
127+
106128
repository = repositories.StopMachine(api_key=self.api_key, logger=self.logger)
107129
repository.stop(id)
108130

@@ -117,6 +139,20 @@ def update(
117139
auto_snapshot_save_count=None,
118140
dynamic_public_ip=None,
119141
):
142+
"""Update machine instance
143+
144+
:param str id: Id of the machine to update [required]
145+
:param str name: New name for the machine
146+
:param int shutdown_timeout_in_hours: Number of hours before machine is shutdown if no one is logged in
147+
via the Paperspace client
148+
:param bool shutdown_timeout_forces: Force shutdown at shutdown timeout, even if there is
149+
a Paperspace client connection
150+
:param bool perform_auto_snapshot: Perform auto snapshots
151+
:param str auto_snapshot_frequency: One of 'hour', 'day', 'week', or None
152+
:param int auto_snapshot_save_count: Number of snapshots to save
153+
:param str dynamic_public_ip: If true, assigns a new public ip address on machine start and releases it
154+
from the account on machine stop
155+
"""
120156
instance = models.Machine(
121157
name=name,
122158
dynamic_public_ip=dynamic_public_ip,
@@ -133,10 +169,10 @@ def update(
133169
def get_utilization(self, id, billing_month):
134170
"""
135171
136-
:param id:
137-
:param billing_month:
172+
:param id: ID of the machine
173+
:param billing_month: Billing month in "YYYY-MM" format
138174
139-
:return:
175+
:return: Machine utilization info
140176
:rtype: models.MachineUtilization
141177
"""
142178
repository = repositories.GetMachineUtilization(api_key=self.api_key, logger=self.logger)
@@ -154,6 +190,13 @@ def delete(self, machine_id, release_public_ip=False):
154190
repository.delete(machine_id, release_public_ip=release_public_ip)
155191

156192
def wait_for_state(self, machine_id, state, interval=5):
193+
"""Wait for defined machine state
194+
195+
:param str machine_id: ID of the machine
196+
:param str state: State of machine to wait for
197+
:param int interval: interval between polls
198+
"""
199+
157200
repository = WaitForState(api_key=self.api_key, logger=self.logger)
158201
repository.wait_for_state(machine_id, state, interval)
159202

@@ -186,30 +229,30 @@ def list(
186229
):
187230
"""
188231
189-
:param str id:
190-
:param str name:
191-
:param str os:
192-
:param int ram:
193-
:param int cpus:
194-
:param str gpu:
195-
:param str storage_total:
196-
:param str storage_used:
197-
:param str usage_rate:
198-
:param int shutdown_timeout_in_hours:
199-
:param bool perform_auto_snapshot:
200-
:param str auto_snapshot_frequency:
201-
:param int auto_snapshot_save_count:
202-
:param str agent_type:
203-
:param datetime created_timestamp:
204-
:param str state:
205-
:param str updates_pending:
206-
:param str network_id:
207-
:param str private_ip_address:
208-
:param str public_ip_address:
209-
:param str region:
210-
:param str user_id:
211-
:param str team_id:
212-
:param datetime last_run_timestamp:
232+
:param str id: Optional machine id to match on
233+
:param str name: Filter by machine name
234+
:param str os: Filter by os used
235+
:param int ram: Filter by machine RAM (in bytes)
236+
:param int cpus: Filter by CPU count
237+
:param str gpu: Filter by GPU type
238+
:param str storage_total: Filter by total storage
239+
:param str storage_used: Filter by storage used
240+
:param str usage_rate: Filter by usage rate
241+
:param int shutdown_timeout_in_hours: Filter by shutdown timeout
242+
:param bool perform_auto_snapshot: Filter by performAutoSnapshot flag
243+
:param str auto_snapshot_frequency: Filter by autoSnapshotFrequency flag
244+
:param int auto_snapshot_save_count: Filter by auto shapshots count
245+
:param str agent_type: Filter by agent type
246+
:param datetime created_timestamp: Filter by date created
247+
:param str state: Filter by state
248+
:param str updates_pending: Filter by updates pending
249+
:param str network_id: Filter by network ID
250+
:param str private_ip_address: Filter by private IP address
251+
:param str public_ip_address: Filter by public IP address
252+
:param str region: Filter by region. One of {CA, NY2, AMS1}
253+
:param str user_id: Filter by user ID
254+
:param str team_id: Filter by team ID
255+
:param str last_run_timestamp: Filter by last run date
213256
214257
:return: List of machines
215258
:rtype: list[models.Machine]

tests/config_files/run.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
apiKey: some_key
2-
cluster: null
2+
#cluster: null # commented to check if missing key does not break the app
33
clusterId: some_cluster_id
44
command: some command
55
container: some_container

0 commit comments

Comments
 (0)