MCPcopy
hub / github.com/google/earthengine-api / promoteArgs

Method promoteArgs

python/ee/function.py:79–119  ·  view source on GitHub ↗

Promotes arguments to their types based on the function's signature. Verifies that all required arguments are provided and no unknown arguments are present. Args: args: A dictionary of keyword arguments to the function. Returns: A dictionary of promoted arguments.

(self, args: dict[str, Any])

Source from the content-addressed store, hash-verified

77 return Function._promoter(result, self.getReturnType())
78
79 def promoteArgs(self, args: dict[str, Any]) -> dict[str, Any]:
80 """Promotes arguments to their types based on the function's signature.
81
82 Verifies that all required arguments are provided and no unknown arguments
83 are present.
84
85 Args:
86 args: A dictionary of keyword arguments to the function.
87
88 Returns:
89 A dictionary of promoted arguments.
90
91 Raises:
92 EEException: If unrecognized arguments are passed or required ones are
93 missing.
94 """
95 signature = self.getSignature()
96 arg_specs = signature['args']
97
98 # Promote all recognized args.
99 promoted_args: dict[str, Any] = {}
100 known: set[str] = set()
101 for arg_spec in arg_specs:
102 name = arg_spec['name']
103 if name in args:
104 promoted_args[name] = Function._promoter(args[name], arg_spec['type'])
105 elif not arg_spec.get('optional'):
106 raise ee_exception.EEException(
107 'Required argument (%s) missing to function: %s'
108 % (name, signature.get('name')))
109 known.add(name)
110
111 # Check for unknown arguments.
112 unknown = set(args.keys()).difference(known)
113 if unknown:
114 raise ee_exception.EEException(
115 'Unrecognized arguments %s to function: %s'
116 % (unknown, signature.get('name'))
117 )
118
119 return promoted_args
120
121 def nameArgs(
122 self,

Callers 12

applyMethod · 0.95
__init__Method · 0.80
__init__Method · 0.80
__init__Method · 0.80
__init__Method · 0.80
initFunction · 0.80
__init__Method · 0.80
__init__Method · 0.80
__init__Method · 0.80
test_promote_argsMethod · 0.80
function.jsFile · 0.80
targetFunction · 0.80

Calls 5

getSignatureMethod · 0.95
keysMethod · 0.80
getMethod · 0.45
addMethod · 0.45
differenceMethod · 0.45

Tested by 1

test_promote_argsMethod · 0.64