MCPcopy Create free account
hub / github.com/StackStorm/st2 / from_model

Method from_model

st2common/st2common/models/api/execution.py:153–172  ·  view source on GitHub ↗
(cls, model, mask_secrets=False)

Source from the content-addressed store, hash-verified

151
152 @classmethod
153 def from_model(cls, model, mask_secrets=False):
154 doc = cls._from_model(model, mask_secrets=mask_secrets)
155
156 doc["result"] = ActionExecutionDB.result.parse_field_value(doc["result"])
157
158 start_timestamp = model.start_timestamp
159 start_timestamp_iso = isotime.format(start_timestamp, offset=False)
160 doc["start_timestamp"] = start_timestamp_iso
161
162 end_timestamp = model.end_timestamp
163 if end_timestamp:
164 end_timestamp_iso = isotime.format(end_timestamp, offset=False)
165 doc["end_timestamp"] = end_timestamp_iso
166 doc["elapsed_seconds"] = (end_timestamp - start_timestamp).total_seconds()
167
168 for entry in doc.get("log", []):
169 entry["timestamp"] = isotime.format(entry["timestamp"], offset=False)
170
171 attrs = {attr: value for attr, value in six.iteritems(doc) if value}
172 return cls(**attrs)
173
174 @classmethod
175 def to_model(cls, instance):

Callers

nothing calls this directly

Calls 4

_from_modelMethod · 0.80
parse_field_valueMethod · 0.80
formatMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected