Skip to content

Commit

Permalink
[Python] Function Keyword Argument and Function Call through Paramete…
Browse files Browse the repository at this point in the history
…r PR (#644)

### GroMEt generation
- Added support for handling the GroMEt primitive "_call"
- Fixed an issue with the unpacking of a tuple from an attribute item
- Fixed an issue with packing of a tuple in function calls.
- Added some additional code to make the handling of Attributes more
robust
- Fixed an issue with functions being used as keyword arguments
- Fixed an issue with port indices being too large in some wires.

### Python to CAST
- Added a table to maintain a function's arguments. This is used to
determine if an argument is being called as a function.
- Added support for generating a primitive "_call" Function Call node
that's used whenever a function that's passed as a function parameter is
being called.

### Other
- Added "_call" primitive to the execution engine's set of primitives in
order to properly support GroMEt generation for it.

### Testing
- Added a test file that checks that the generation and use of the
"_call" primitive is correct and consistent.

Resolves #592

---------

Co-authored-by: Vincent Raymond <[email protected]>
Co-authored-by: Gus Hahn-Powell <[email protected]> bd15457
  • Loading branch information
github-actions[bot] and vincentraymond-ua committed Nov 18, 2023
1 parent 2329d9d commit 371381e
Show file tree
Hide file tree
Showing 1,200 changed files with 305,825 additions and 223,258 deletions.
70 changes: 69 additions & 1 deletion api/python/skema/gromet/execution_engine/types/other.html
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,20 @@ <h1 class="title">Module <code>skema.gromet.execution_engine.types.other</code><
documentation = &#34;&#34;

def exec(input: int) -&gt; range:
return range(input)</code></pre>
return range(input)


class Call:
source_language_name = {&#34;CAST&#34;: &#34;_call&#34;}
inputs = [
Field(&#34;func_name&#34;, &#34;string&#34;),
Field(&#34;args&#34;,&#34;Any&#34;,variatic=True)
]
outputs = [Field(&#34;call_output&#34;, &#34;Any&#34;)]
shorthand = &#34;_call&#34;
documentation = &#34;&#34;

# TODO: exec</code></pre>
</details>
</section>
<section>
Expand Down Expand Up @@ -253,6 +266,51 @@ <h3>Class variables</h3>
</dd>
</dl>
</dd>
<dt id="skema.gromet.execution_engine.types.other.Call"><code class="flex name class">
<span>class <span class="ident">Call</span></span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">class Call:
source_language_name = {&#34;CAST&#34;: &#34;_call&#34;}
inputs = [
Field(&#34;func_name&#34;, &#34;string&#34;),
Field(&#34;args&#34;,&#34;Any&#34;,variatic=True)
]
outputs = [Field(&#34;call_output&#34;, &#34;Any&#34;)]
shorthand = &#34;_call&#34;
documentation = &#34;&#34;

# TODO: exec</code></pre>
</details>
<h3>Class variables</h3>
<dl>
<dt id="skema.gromet.execution_engine.types.other.Call.documentation"><code class="name">var <span class="ident">documentation</span></code></dt>
<dd>
<div class="desc"></div>
</dd>
<dt id="skema.gromet.execution_engine.types.other.Call.inputs"><code class="name">var <span class="ident">inputs</span></code></dt>
<dd>
<div class="desc"></div>
</dd>
<dt id="skema.gromet.execution_engine.types.other.Call.outputs"><code class="name">var <span class="ident">outputs</span></code></dt>
<dd>
<div class="desc"></div>
</dd>
<dt id="skema.gromet.execution_engine.types.other.Call.shorthand"><code class="name">var <span class="ident">shorthand</span></code></dt>
<dd>
<div class="desc"></div>
</dd>
<dt id="skema.gromet.execution_engine.types.other.Call.source_language_name"><code class="name">var <span class="ident">source_language_name</span></code></dt>
<dd>
<div class="desc"></div>
</dd>
</dl>
</dd>
<dt id="skema.gromet.execution_engine.types.other.Cast"><code class="flex name class">
<span>class <span class="ident">Cast</span></span>
</code></dt>
Expand Down Expand Up @@ -780,6 +838,16 @@ <h4><code><a title="skema.gromet.execution_engine.types.other.CASTGenericNext" h
</ul>
</li>
<li>
<h4><code><a title="skema.gromet.execution_engine.types.other.Call" href="#skema.gromet.execution_engine.types.other.Call">Call</a></code></h4>
<ul class="">
<li><code><a title="skema.gromet.execution_engine.types.other.Call.documentation" href="#skema.gromet.execution_engine.types.other.Call.documentation">documentation</a></code></li>
<li><code><a title="skema.gromet.execution_engine.types.other.Call.inputs" href="#skema.gromet.execution_engine.types.other.Call.inputs">inputs</a></code></li>
<li><code><a title="skema.gromet.execution_engine.types.other.Call.outputs" href="#skema.gromet.execution_engine.types.other.Call.outputs">outputs</a></code></li>
<li><code><a title="skema.gromet.execution_engine.types.other.Call.shorthand" href="#skema.gromet.execution_engine.types.other.Call.shorthand">shorthand</a></code></li>
<li><code><a title="skema.gromet.execution_engine.types.other.Call.source_language_name" href="#skema.gromet.execution_engine.types.other.Call.source_language_name">source_language_name</a></code></li>
</ul>
</li>
<li>
<h4><code><a title="skema.gromet.execution_engine.types.other.Cast" href="#skema.gromet.execution_engine.types.other.Cast">Cast</a></code></h4>
<ul class="">
<li><code><a title="skema.gromet.execution_engine.types.other.Cast.documentation" href="#skema.gromet.execution_engine.types.other.Cast.documentation">documentation</a></code></li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ <h3>Instance variables</h3>
<h3>Methods</h3>
<dl>
<dt id="skema.img2mml.models.decoders.xfmer_decoder.Transformer_Decoder.create_pad_mask"><code class="name flex">
<span>def <span class="ident">create_pad_mask</span></span>(<span>self, matrix: <built-in method tensor of type object at 0x7f04a9d5b500>, pad_token: int) ‑> <built-in method tensor of type object at 0x7f04a9d5b500></span>
<span>def <span class="ident">create_pad_mask</span></span>(<span>self, matrix: <built-in method tensor of type object at 0x7ff10595b500>, pad_token: int) ‑> <built-in method tensor of type object at 0x7ff10595b500></span>
</code></dt>
<dd>
<div class="desc"></div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ <h3>Class variables</h3>
<h3>Methods</h3>
<dl>
<dt id="skema.img2mml.models.encoding.positional_encoding_for_xfmer.PositionalEncoding.forward"><code class="name flex">
<span>def <span class="ident">forward</span></span>(<span>self, x: <built-in method tensor of type object at 0x7f04a9d5b500>) ‑> <built-in method tensor of type object at 0x7f04a9d5b500></span>
<span>def <span class="ident">forward</span></span>(<span>self, x: <built-in method tensor of type object at 0x7ff10595b500>) ‑> <built-in method tensor of type object at 0x7ff10595b500></span>
</code></dt>
<dd>
<div class="desc"><p>Defines the computation performed at every call.</p>
Expand Down
Loading

0 comments on commit 371381e

Please sign in to comment.