Coverage for skema/gromet/fn/gromet_port.py: 86%

85 statements  

« prev     ^ index     » next       coverage.py v7.5.0, created at 2024-04-30 17:15 +0000

1# coding: utf-8 

2 

3""" 

4 Grounded Model Exchange (GroMEt) schema for Function Networks 

5 

6 This document defines the GroMEt Function Network data model. Note that Metadata is defined in separate spec. __Using Swagger to Generate Class Structure__ To automatically generate Python or Java models corresponding to this document, you can use [swagger-codegen](https://swagger.io/tools/swagger-codegen/). This can be used to generate the client code based off of this spec, and in the process this will generate the data model class structure. 1. Install via the method described for your operating system [here](https://github.com/swagger-api/swagger-codegen#Prerequisites). Make sure to install a version after 3.0 that will support openapi 3. 2. Run swagger-codegen with the options in the example below. The URL references where the yaml for this documentation is stored on github. Make sure to replace CURRENT_VERSION with the correct version. (The current version is `0.1.7`.) To generate Java classes rather, change the `-l python` to `-l java`. Change the value to the `-o` option to the desired output location. ``` swagger-codegen generate -l python -o ./client -i https://raw.githubusercontent.com/ml4ai/automates-v2/master/docs/source/gromet_FN_v{CURRENT_VERSION}.yaml ``` 3. Once it executes, the client code will be generated at your specified location. For python, the classes will be located in `$OUTPUT_PATH/skema.gromet.fn.`. For java, they will be located in `$OUTPUT_PATH/src/main/java/io/swagger/client/model/` If generating GroMEt schema data model classes in SKEMA (AutoMATES), then after generating the above, follow the instructions here: ``` <automates>/automates/model_assembly/gromet/model/README.md ``` # noqa: E501 

7 

8 OpenAPI spec version: 0.1.10 

9 Contact: claytonm@arizona.edu 

10 Generated by: https://github.com/swagger-api/swagger-codegen.git 

11""" 

12 

13import pprint 

14import re # noqa: F401 

15 

16import six 

17from skema.gromet.fn.gromet_object import GrometObject # noqa: F401,E501 

18 

19class GrometPort(GrometObject): 

20 """NOTE: This class is auto generated by the swagger code generator program. 

21 

22 Do not edit the class manually. 

23 """ 

24 """ 

25 Attributes: 

26 swagger_types (dict): The key is attribute name 

27 and the value is attribute type. 

28 attribute_map (dict): The key is attribute name 

29 and the value is json key in definition. 

30 """ 

31 swagger_types = { 

32 'id': 'int', 

33 'name': 'str', 

34 'box': 'int', 

35 'default_value': 'LiteralValue', 

36 'gromet_type': 'str' 

37 } 

38 if hasattr(GrometObject, "swagger_types"): 

39 swagger_types.update(GrometObject.swagger_types) 

40 

41 attribute_map = { 

42 'id': 'id', 

43 'name': 'name', 

44 'box': 'box', 

45 'default_value': 'default_value', 

46 'gromet_type': 'gromet_type' 

47 } 

48 if hasattr(GrometObject, "attribute_map"): 

49 attribute_map.update(GrometObject.attribute_map) 

50 

51 def __init__(self, id=None, name=None, box=None, default_value=None, gromet_type='GrometPort', *args, **kwargs): # noqa: E501 

52 """GrometPort - a model defined in Swagger""" # noqa: E501 

53 self._id = None 

54 self._name = None 

55 self._box = None 

56 self._default_value = None 

57 self._gromet_type = None 

58 self.discriminator = None 

59 if id is not None: 

60 self.id = id 

61 if name is not None: 

62 self.name = name 

63 if box is not None: 

64 self.box = box 

65 if default_value is not None: 

66 self.default_value = default_value 

67 if gromet_type is not None: 

68 self.gromet_type = gromet_type 

69 GrometObject.__init__(self, *args, **kwargs) 

70 

71 @property 

72 def id(self): 

73 """Gets the id of this GrometPort. # noqa: E501 

74 

75 The Port id is a natural number that represent the order of the Port on the Box. This enables the following: (1) BoxFunctions with FN context will be able to unambiguously match the \"calling\" BoxFunction Port Inputs (pif) (and Port Outputs, pof) to their corresponding Outer Port Inputs (opi) (and Outer Port Outputs, opo) based in the ordering of the ids of each Port. (2) Loop Port Input (pil) id ordering will match the Loop Port Output (pol) as well as the ordering of the Port Inputs and Port Outputs of the calling loop body Function. # noqa: E501 

76 

77 :return: The id of this GrometPort. # noqa: E501 

78 :rtype: int 

79 """ 

80 return self._id 

81 

82 @id.setter 

83 def id(self, id): 

84 """Sets the id of this GrometPort. 

85 

86 The Port id is a natural number that represent the order of the Port on the Box. This enables the following: (1) BoxFunctions with FN context will be able to unambiguously match the \"calling\" BoxFunction Port Inputs (pif) (and Port Outputs, pof) to their corresponding Outer Port Inputs (opi) (and Outer Port Outputs, opo) based in the ordering of the ids of each Port. (2) Loop Port Input (pil) id ordering will match the Loop Port Output (pol) as well as the ordering of the Port Inputs and Port Outputs of the calling loop body Function. # noqa: E501 

87 

88 :param id: The id of this GrometPort. # noqa: E501 

89 :type: int 

90 """ 

91 

92 self._id = id 

93 

94 @property 

95 def name(self): 

96 """Gets the name of this GrometPort. # noqa: E501 

97 

98 

99 :return: The name of this GrometPort. # noqa: E501 

100 :rtype: str 

101 """ 

102 return self._name 

103 

104 @name.setter 

105 def name(self, name): 

106 """Sets the name of this GrometPort. 

107 

108 

109 :param name: The name of this GrometPort. # noqa: E501 

110 :type: str 

111 """ 

112 

113 self._name = name 

114 

115 @property 

116 def box(self): 

117 """Gets the box of this GrometPort. # noqa: E501 

118 

119 Index to the Box that the Port belongs to. # noqa: E501 

120 

121 :return: The box of this GrometPort. # noqa: E501 

122 :rtype: int 

123 """ 

124 return self._box 

125 

126 @box.setter 

127 def box(self, box): 

128 """Sets the box of this GrometPort. 

129 

130 Index to the Box that the Port belongs to. # noqa: E501 

131 

132 :param box: The box of this GrometPort. # noqa: E501 

133 :type: int 

134 """ 

135 

136 self._box = box 

137 

138 @property 

139 def default_value(self): 

140 """Gets the default_value of this GrometPort. # noqa: E501 

141 

142 

143 :return: The default_value of this GrometPort. # noqa: E501 

144 :rtype: LiteralValue 

145 """ 

146 return self._default_value 

147 

148 @default_value.setter 

149 def default_value(self, default_value): 

150 """Sets the default_value of this GrometPort. 

151 

152 

153 :param default_value: The default_value of this GrometPort. # noqa: E501 

154 :type: LiteralValue 

155 """ 

156 

157 self._default_value = default_value 

158 

159 @property 

160 def gromet_type(self): 

161 """Gets the gromet_type of this GrometPort. # noqa: E501 

162 

163 

164 :return: The gromet_type of this GrometPort. # noqa: E501 

165 :rtype: str 

166 """ 

167 return self._gromet_type 

168 

169 @gromet_type.setter 

170 def gromet_type(self, gromet_type): 

171 """Sets the gromet_type of this GrometPort. 

172 

173 

174 :param gromet_type: The gromet_type of this GrometPort. # noqa: E501 

175 :type: str 

176 """ 

177 

178 self._gromet_type = gromet_type 

179 

180 def to_dict(self): 

181 """Returns the model properties as a dict""" 

182 result = {} 

183 

184 for attr, _ in six.iteritems(self.swagger_types): 

185 value = getattr(self, attr) 

186 if isinstance(value, list): 

187 result[attr] = list(map( 

188 lambda x: x.to_dict() if hasattr(x, "to_dict") else x, 

189 value 

190 )) 

191 elif hasattr(value, "to_dict"): 

192 result[attr] = value.to_dict() 

193 elif isinstance(value, dict): 

194 result[attr] = dict(map( 

195 lambda item: (item[0], item[1].to_dict()) 

196 if hasattr(item[1], "to_dict") else item, 

197 value.items() 

198 )) 

199 else: 

200 result[attr] = value 

201 if issubclass(GrometPort, dict): 

202 for key, value in self.items(): 

203 result[key] = value 

204 

205 return result 

206 

207 def to_str(self): 

208 """Returns the string representation of the model""" 

209 return pprint.pformat(self.to_dict()) 

210 

211 def __repr__(self): 

212 """For `print` and `pprint`""" 

213 return self.to_str() 

214 

215 def __eq__(self, other): 

216 """Returns true if both objects are equal""" 

217 if not isinstance(other, GrometPort): 

218 return False 

219 

220 return self.__dict__ == other.__dict__ 

221 

222 def __ne__(self, other): 

223 """Returns true if both objects are not equal""" 

224 return not self == other