Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python scalability banks #873

Merged
merged 70 commits into from
Jan 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
239e875
add federated send class test
housengw Jan 5, 2022
a294016
add more send class tests
housengw Jan 5, 2022
24e8a2b
add no react test
housengw Jan 22, 2022
c63aceb
Updated the Python generator to use the new bank index scheme
Soroosh129 Jan 22, 2022
90ca83d
Added the nested banks test
Soroosh129 Jan 22, 2022
85ad7ae
Comments only
Soroosh129 Jan 22, 2022
12b9192
Added PyUtil
Soroosh129 Jan 22, 2022
ca47625
Updated source code format of the PythonGenerator
Soroosh129 Jan 22, 2022
8943031
Fixed syntax error
Soroosh129 Jan 22, 2022
9c8b937
First step toward supporting sending/receiving to contained banks (C …
Soroosh129 Jan 22, 2022
22cb830
Interim commit to fix the Python side
Soroosh129 Jan 22, 2022
9b2c4a6
Slightly adjusted example
Soroosh129 Jan 24, 2022
94142e1
Skeleton of the intersection demo in ROS
Soroosh129 Jan 24, 2022
2495ab5
Revert "Skeleton of the intersection demo in ROS"
Soroosh129 Jan 24, 2022
0cdba6d
Revert "Slightly adjusted example"
Soroosh129 Jan 24, 2022
67bb9a5
Ported LinguaFrancaScopingTest to Java
lhstrh Jan 14, 2022
413e8e3
Ported one more class and added a utility.
lhstrh Jan 14, 2022
1ef5a51
Respond to comments from @oowekyala
lhstrh Jan 20, 2022
943cae0
Update org.lflang.tests/src/org/lflang/tests/compiler/LinguaFrancaAST…
lhstrh Jan 23, 2022
0d7363a
cleanup scripts
housengw Jan 20, 2022
06610a9
improve log readability
housengw Jan 20, 2022
0e8f6b5
update dev docs
housengw Jan 20, 2022
99c939b
nonfunctional double unlock demo
housengw Jan 15, 2022
9433261
refactor Key fob demo
housengw Jan 17, 2022
b73da8c
rename lock_status to lock_state
housengw Jan 17, 2022
f3124e2
functional double unlock demo without autolock
housengw Jan 17, 2022
8852721
refactor messages
housengw Jan 18, 2022
446dcc0
resolve conflicts
housengw Jan 21, 2022
9744d3d
add autolock feature
housengw Jan 18, 2022
3716c5c
added intermediate logical action
housengw Jan 18, 2022
e24d54d
add skeleton of Tester
housengw Jan 18, 2022
58709a5
add run scripts and fix tester
housengw Jan 19, 2022
12b9e2a
add readme for double unlock demo
housengw Jan 21, 2022
603fde3
add link to demo
housengw Jan 21, 2022
e438f0b
rename tester to simulator
housengw Jan 22, 2022
17f9c23
Update DoubleUnlockDemo.lf
housengw Jan 21, 2022
8ca7994
add comment and clean up
housengw Jan 22, 2022
22e2299
Update RELEASES.md.
petervdonovan Jan 19, 2022
f1ef334
Update RELEASES.md.
petervdonovan Jan 19, 2022
b3f902a
CI: Re-order steps.
petervdonovan Jan 19, 2022
49c2f91
Python: Handle empty output.
petervdonovan Jan 19, 2022
683dd66
Revert "Python: Handle empty output."
petervdonovan Jan 19, 2022
c6f1f4c
LFCommand: Do not forget to shut down thread pool.
petervdonovan Jan 19, 2022
505cda4
Python: Tolerate output from an older Pylint version.
petervdonovan Jan 20, 2022
6c5b62b
Error reporting: One more special case for code generators.
petervdonovan Jan 20, 2022
80e70a7
Fixed compile errors
Soroosh129 Jan 24, 2022
c57e6f7
Merge remote-tracking branch 'origin/scalability-banks' into python-s…
Soroosh129 Jan 24, 2022
c98f551
Fixed merge artifacts
Soroosh129 Jan 24, 2022
84d8f27
Tests: Code block start/end may be commented out.
petervdonovan Jan 25, 2022
5013c14
Addressed issue in the workaround
Soroosh129 Jan 25, 2022
4e6a93c
Applied suggestion from @petervdonovan
Soroosh129 Jan 25, 2022
4156312
Merge remote-tracking branch 'origin/python-scalability-banks' into p…
Soroosh129 Jan 25, 2022
419fa73
Merge remote-tracking branch 'origin/master' into python-scalability-…
Soroosh129 Jan 25, 2022
2edf29c
Merge remote-tracking branch 'origin/python-scalability-banks' into p…
Soroosh129 Jan 25, 2022
32f2804
Use the __main__ module to load functions
Soroosh129 Jan 25, 2022
845b9b3
Added timeouts to tests
Soroosh129 Jan 25, 2022
1b399eb
Use the docker hub image for RTI in the compose file
Soroosh129 Jan 25, 2022
4e63977
Updated test since port values are read-only
Soroosh129 Nov 14, 2021
19ccbf6
Added containarized variant of send class
Soroosh129 Jan 26, 2022
634ed8e
New lines
Soroosh129 Jan 26, 2022
3c08c56
Added to RELEASE.md
Soroosh129 Jan 26, 2022
e3914ad
Merge pull request #826 from lf-lang/python-send-class-tests
Soroosh129 Jan 26, 2022
6d6d653
Fixed a bug in the Python code
Soroosh129 Jan 26, 2022
9d53914
Added tests
Soroosh129 Jan 26, 2022
584a21e
Factored out redundant code
Soroosh129 Jan 26, 2022
9fd5c33
Merge remote-tracking branch 'origin/master' into python-scalability-…
Soroosh129 Jan 27, 2022
d1375be
Updated RELEASES.md
Soroosh129 Jan 27, 2022
d93492d
Documentation only
Soroosh129 Jan 27, 2022
5841696
Fixed the usage of the Make class
Soroosh129 Jan 27, 2022
a776a10
Comments only
Soroosh129 Jan 28, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,34 @@ The `lfc` command line application is suitable for:
- [C++](https://github.com/icyphy/lingua-franca/wiki/Writing-Reactors-in-Cpp)
- [Python](https://github.com/icyphy/lingua-franca/wiki/Writing-Reactors-in-Python)
- [TypeScript](https://github.com/icyphy/lingua-franca/wiki/Writing-Reactors-in-TypeScript)

### Bug Fixes
- fixed an issue where top-level custom Python classes were being serialized
incorrectly

### New Features
- [Python] `bank_index` (useful for banks of reactors) is now a proper parameter
that can be passed down the reactor hierarchy via parameter assignment. For
example, the following code snippet now works as expected:
```Python
target Python;
reactor Bar (bank_index(0), parent_bank_index(0)) {
reaction(startup) {=
print(f"My parent bank index is {self.parent_bank_index}.")
=}
}
reactor Foo (bank_index(0)) {
bar = new[2] Bar(parent_bank_index = bank_index)
}
main reactor {
f = new[2] Foo()
}
```
The output will be:

```bash
My parent bank index is 0.
My parent bank index is 1.
My parent bank index is 1.
My parent bank index is 0.
```
10 changes: 6 additions & 4 deletions org.lflang.tests/src/org/lflang/tests/lsp/ErrorInserter.java
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,13 @@ private void alter(BiFunction<ListIterator<String>, String, Boolean> alterer) {
int lineNumber = 0;
while (it.hasNext()) {
String current = it.next();
if (current.contains("=}")) inCodeBlock = false;
String uncommented = current.contains("//") ?
current.substring(0, current.indexOf("//")) : current;
if (uncommented.contains("=}")) inCodeBlock = false;
if (inCodeBlock && alterer.apply(it, current)) badLines.add(lineNumber);
if (current.contains("{=")) inCodeBlock = true;
if (current.contains("{=") && current.contains("=}")) {
inCodeBlock = current.lastIndexOf("{=") > current.lastIndexOf("=}");
if (uncommented.contains("{=")) inCodeBlock = true;
if (uncommented.contains("{=") && uncommented.contains("=}")) {
inCodeBlock = uncommented.lastIndexOf("{=") > uncommented.lastIndexOf("=}");
}
lineNumber++;
}
Expand Down
2 changes: 1 addition & 1 deletion org.lflang/src/lib/py/reactor-c-py
10 changes: 6 additions & 4 deletions org.lflang/src/org/lflang/federated/FedASTUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -619,10 +619,12 @@ private static void addNetworkOutputControlReaction(
Input newTriggerForControlReactionVariable = factory.createInput();
newTriggerForControlReactionVariable.setName(triggerName);

// The input needs a type. All targets have a Time type, so we use that.
Type portType = factory.createType();
portType.setId(generator.getTargetTypes().getTargetTimeType());
newTriggerForControlReactionVariable.setType(portType);
if (generator.getTarget().requiresTypes) {
// The input needs a type. All targets have a Time type, so we use that.
Type portType = factory.createType();
portType.setId(generator.getTargetTypes().getTargetTimeType());
newTriggerForControlReactionVariable.setType(portType);
}

top.getInputs().add(newTriggerForControlReactionVariable);

Expand Down
2 changes: 1 addition & 1 deletion org.lflang/src/org/lflang/generator/c/CGenerator.xtend
Original file line number Diff line number Diff line change
Expand Up @@ -886,7 +886,7 @@ class CGenerator extends GeneratorBase {

if (targetConfig.dockerOptions !== null) {
if (isFederated) {
appendRtiToDockerComposeServices(dockerComposeServices, rtiName, "rti:rti", federates.size);
appendRtiToDockerComposeServices(dockerComposeServices, rtiName, "lflang/rti:rti", federates.size);
}
writeFederatesDockerComposeFile(dockerComposeDir, dockerComposeServices, dockerComposeNetworkName);
}
Expand Down
88 changes: 88 additions & 0 deletions org.lflang/src/org/lflang/generator/python/PyUtil.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/* Utilities for Python code generation. */

/*************
Copyright (c) 2019-2021, The University of California at Berkeley.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***************/

package org.lflang.generator.python;

import org.lflang.generator.ReactorInstance;
import org.lflang.generator.c.CUtil;


/**
* A collection of utilities for Python code generation.
* This class inherits from CUtil but overrides a few methods to
* codify the coding conventions for the Python target code generator.
* I.e., it defines how some variables are named and referenced.
* @author{Edward A. Lee <[email protected]>}
* @author{Soroush Bateni <[email protected]>}
*/
public class PyUtil extends CUtil {

/**
* Return the name of the list of Python class instances that contains the
* specified reactor instance. This is similar to
* {@link #reactorRef(ReactorInstance)} except that it does not index into
* the list.
*
* @param instance The reactor instance.
*/
static public String reactorRefName(ReactorInstance instance) {
return instance.uniqueID() + "_lf";
}

/**
* Return a reference to the list of Python class instances that contains
* the specified reactor instance. The returned string has the form
* list_name[runtimeIndex], where list_name is the name of the list of
* Python class instances that contains this reactor instance. If
* runtimeIndex is null, then it is replaced by the expression returned by
* {@link runtimeIndex(ReactorInstance)} or 0 if there are no banks.
*
* @param instance The reactor instance.
* @param runtimeIndex An optional expression to use to address bank
* members. If this is null, the expression used will be
* that returned by
* {@link #runtimeIndex(ReactorInstance)}.
*/
static public String reactorRef(ReactorInstance instance, String runtimeIndex) {
if (runtimeIndex == null) runtimeIndex = runtimeIndex(instance);
return PyUtil.reactorRefName(instance) + "[" + runtimeIndex + "]";
}

/**
* Return a reference to the list of Python class instances that contains
* the specified reactor instance. The returned string has the form
* list_name[j], where list_name is the name of the list of of Python class
* instances that contains this reactor instance and j is the expression
* returned by {@link #runtimeIndex(ReactorInstance)} or 0 if there are no
* banks.
*
* @param instance The reactor instance.
*/
static public String reactorRef(ReactorInstance instance) {
return PyUtil.reactorRef(instance, null);
}

}
Loading