1- import sys
1+ import random
22import re
3- import os .path as osp
3+ import string
4+
45from .future import DSSFuture
5- from ..utils import DataikuException
6- import random , string
6+
77
88def random_string (length ):
99 return '' .join (random .choice (string .ascii_letters ) for _ in range (length ))
1010
11+
1112class DSSApp (object ):
1213 """
13- A handle to interact with a app on the DSS instance.
14- Do not create this class directly, instead use :meth:`dataikuapi.DSSClient.get_app``
14+ A handle to interact with an application on the DSS instance.
15+ Do not create this class directly, instead use :meth:`dataikuapi.DSSClient.get_app`
1516 """
1617 def __init__ (self , client , app_id ):
17- self .client = client
18- self .app_id = app_id
18+ self .client = client
19+ self .app_id = app_id
1920
2021 ########################################################
2122 # Instances
2223 ########################################################
2324
2425 def create_instance (self , instance_key , instance_name , wait = True ):
2526 """
26- Creates a new instance of this app . Each instance. must have a globally unique
27+ Creates a new instance of this application . Each instance. must have a globally unique
2728 instance key, separate from any project key across the whole DSS instance
2829
2930 :return:
3031 """
3132 future_resp = self .client ._perform_json (
3233 "POST" , "/apps/%s/instances" % self .app_id , body = {
33- "targetProjectKey" : instance_key ,
34- "targetProjectName" : instance_name
35- })
34+ "targetProjectKey" : instance_key ,
35+ "targetProjectName" : instance_name
36+ })
3637 future = DSSFuture (self .client , future_resp .get ("jobId" , None ), future_resp )
3738 if wait :
38- result = future .wait_for_result ()
39+ future .wait_for_result ()
3940 return DSSAppInstance (self .client , instance_key )
4041 else :
4142 return future
@@ -46,13 +47,13 @@ def make_random_project_key(self):
4647
4748 def create_temporary_instance (self ):
4849 """
49- Creates a new temporary instance of this app .
50+ Creates a new temporary instance of this application .
5051 The return value should be used as a Python context manager. Upon exit, the temporary app
5152 instance is deleted
5253 :return a :class:`TemporaryDSSAppInstance`
5354 """
5455 key = self .make_random_project_key ()
55- instance = self .create_instance (key , key , True )
56+ self .create_instance (key , key , True )
5657 return TemporaryDSSAppInstance (self .client , key )
5758
5859 def list_instance_keys (self ):
@@ -85,7 +86,7 @@ def get_manifest(self):
8586class DSSAppManifest (object ):
8687
8788 def __init__ (self , client , raw_data , project_key = None ):
88- """The manifest for an app . Do not create this class directly"""
89+ """The manifest for an application . Do not create this class directly"""
8990 self .client = client
9091 self .raw_data = raw_data
9192 self .project_key = project_key
@@ -110,29 +111,29 @@ def save(self):
110111class DSSAppInstance (object ):
111112
112113 def __init__ (self , client , project_key ):
113- self .client = client
114- self .project_key = project_key
114+ self .client = client
115+ self .project_key = project_key
115116
116117 def get_as_project (self ):
117118 """
118- Get the :class:`dataikuapi.dss.project DSSProject` corresponding to this app instance
119+ Get the :class:`dataikuapi.dss.project DSSProject` corresponding to this application instance
119120 """
120121 return self .client .get_project (self .project_key )
121122
122123 def get_manifest (self ):
123124 """
124- Get the app manifest for this instance, as a :class:`DSSAppManifest`
125+ Get the application manifest for this instance, as a :class:`DSSAppManifest`
125126 """
126127 raw_data = self .client ._perform_json ("GET" , "/projects/%s/app-manifest" % self .project_key )
127128 return DSSAppManifest (self .client , raw_data )
128129
130+
129131class TemporaryDSSAppInstance (DSSAppInstance ):
130132 """internal class"""
131133
132134 def __init__ (self , client , project_key ):
133135 DSSAppInstance .__init__ (self , client ,project_key )
134136
135-
136137 def close (self ):
137138 self .get_as_project ().delete (drop_data = True )
138139
0 commit comments