MCPcopy Index your code
hub / github.com/google/earthengine-api / encode_cloud_value

Method encode_cloud_value

python/ee/computedobject.py:139–170  ·  view source on GitHub ↗
(self, encoder: Any)

Source from the content-addressed store, hash-verified

137 }
138
139 def encode_cloud_value(self, encoder: Any) -> dict[str, Any]:
140 if self.isVariable():
141 ref = self.varName
142 if ref is None and isinstance(
143 getattr(encoder, '__self__'), serializer.Serializer):
144 ref = encoder.__self__.unbound_name
145 if ref is None:
146 # We are trying to call getInfo() or make some other server call inside
147 # a function passed to collection.map() or .iterate(), and the call uses
148 # one of the function arguments. The argument will be unbound outside of
149 # the map operation and cannot be evaluated. See the Count Functions
150 # case in customfunction.py for details on the unbound_name mechanism.
151 raise ee_exception.EEException(
152 "A mapped function's arguments cannot be used in "
153 'client-side operations'
154 )
155 return {'argumentReference': ref}
156 else:
157 if isinstance(self.func, str):
158 invocation = {'functionName': self.func}
159 else:
160 assert self.func is not None
161 invocation = self.func.encode_cloud_invocation(encoder)
162
163 # Encode all arguments recursively.
164 encoded_args: dict[str, Any] = {}
165 for name in sorted(self.args):
166 value = self.args[name]
167 if value is not None:
168 encoded_args[name] = {'valueReference': encoder(value)}
169 invocation['arguments'] = encoded_args
170 return {'functionInvocationValue': invocation}
171
172 @_utils.accept_opt_prefix('opt_pretty')
173 def serialize(self, pretty: bool = False, for_cloud_api: bool = True) -> str:

Callers 1

Calls 2

isVariableMethod · 0.95

Tested by 1