OpenROAD icon indicating copy to clipboard operation
OpenROAD copied to clipboard

src: fix PyMain arguments forwarding

Open proppy opened this issue 3 years ago • 16 comments

This copy all the arguments, instead of just forwarding argv[0], reusing the same code that was previously in https://github.com/The-OpenROAD-Project/OpenROAD/commit/47e8b5f57e2f680172f99c0433c01ed91fcf7fe7#diff-7c2e2869b9670e340a14a2b2ed1cc45a9f85fb8b219a4c1f06fdd467f49375c1L216-L222

Fixes: #2287

proppy avatar Sep 21 '22 09:09 proppy

PTAL, signed the commit so that DCO check passes.

proppy avatar Sep 21 '22 09:09 proppy

-exit handles this case as mentioned in the issue so I see no need for this PR. Do you disagree?

maliberty avatar Sep 21 '22 14:09 maliberty

I guess I'm confused because OpenLane doesn't seem to be passing -exit to any of those invocation: https://github.com/The-OpenROAD-Project/OpenLane/search?q=%24%3A%3Aenv%28OPENROAD_BIN%29

Are you saying that they depends on a buggy behavior? (i.e: the fact that before https://github.com/The-OpenROAD-Project/OpenROAD/commit/47e8b5f57e2f680172f99c0433c01ed91fcf7fe7#diff-7c2e2869b9670e340a14a2b2ed1cc45a9f85fb8b219a4c1f06fdd467f49375c1L216-L222 openroad didn't drop into an interactive shell if -exit was omitted)

proppy avatar Sep 21 '22 15:09 proppy

It may have been buggy before but I believe this is the correct behavior. This is how OR works in tcl mode so I would expect it to be the same with -python.

maliberty avatar Sep 21 '22 15:09 maliberty

It may have been buggy before

So would you recommend instead to do a PR against OpenLane to add -exit flag everywhere they invoke OpenROAD?

proppy avatar Sep 21 '22 15:09 proppy

It may have been buggy before

So would you recommend instead to do a PR against OpenLane to add -exit flag everywhere they invoke OpenROAD?

I see for tcl they use run_openroad_script which handles adding -exit. I don't know if that should be adapted to work with python or what you suggest is ok. Best to ask @donn

maliberty avatar Sep 21 '22 15:09 maliberty

I see a few other project not passing -exit, so we should make sure we notify them as well:

  • https://github.com/AUCOHL/DFFRAM/blob/abcc1b312d9d672cbe91743c432e1a90a7fe139d/dffram.py#L163
  • https://github.com/TILOS-AI-Institute/MacroPlacement/blob/f59286b3164b2f7ccdbf7a913f827af628f139dd/Flows/util/RePlAceFlow/runme#L5

proppy avatar Sep 21 '22 15:09 proppy

Lets' continue the discussion here: https://github.com/The-OpenROAD-Project/OpenLane/issues/1387

proppy avatar Sep 21 '22 16:09 proppy

As commented in https://github.com/The-OpenROAD-Project/OpenLane/pull/1388#issuecomment-1253991240, reopening to continue to discuss this, as I can't seem to find a good way to pass -exit to an openroad -python script.py invocation that also expect to process additional flags in python.

proppy avatar Sep 21 '22 17:09 proppy

OR doesn't take script arguments in TCL. It does seem like a nice capability though. If you want to rework this PR to take arguments but still respect the -exit convention (ie without it the tool stays open) I am open to it.

maliberty avatar Sep 21 '22 17:09 maliberty

OR doesn't take script arguments in TCL. It does seem like a nice capability though

It did seem that version <https://github.com/The-OpenROAD-Project/OpenROAD/commit/47e8b5f57e2f680172f99c0433c01ed91fcf7fe7#diff-7c2e2869b9670e340a14a2b2ed1cc45a9f85fb8b219a4c1f06fdd467f49375c1L216-L222 supported it, which apparently ended up having OpenLane depend on it.

Happy to re-work the PR, but it's unfortunate that OpenLane is broken with HEAD. It does seems that some CI check failed: https://jenkins.openroad.tools/job/OpenLane-Public/1300/ but I'm curious why it isn't surfaced on https://github.com/The-OpenROAD-Project/OpenROAD/pull/1849 as it seems useful (even just as a FYI) to understand that a change break a downstream package.

proppy avatar Sep 21 '22 18:09 proppy

There is a CI problem but it isn't related to the python PR but to sta updates

maliberty avatar Sep 21 '22 20:09 maliberty

PTAL, added support for -exit and flag forwarding to -python to restore the previous behavior that OpenLane depends on (and allow us to proceed with https://github.com/The-OpenROAD-Project/OpenLane/pull/1388).

tests

🚫 script, 🚫 arguments, 🚫 -exit

OpenROAD 🧁 ./build/src/openroad -python 
OpenROAD v2.0-4989-gb3821e409 
This program is licensed under the BSD-3 license. See the LICENSE file for details.
Components of this program may be licensed under more restrictive licenses which must be honored.
[WARNING ORD-0039] .openroad ignored with -python
Python 3.10.7 (main, Sep  8 2022, 14:34:29) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 

🟢 script, 🚫 arguments, 🚫 -exit

OpenROAD 🍧 cat foo.py 
import sys
print('hello from openroad', sys.argv)
OpenROAD 🧁 ./build/src/openroad -python foo.py
OpenROAD v2.0-4990-gdf3add309 
This program is licensed under the BSD-3 license. See the LICENSE file for details.
Components of this program may be licensed under more restrictive licenses which must be honored.
[WARNING ORD-0039] .openroad ignored with -python
hello from openroad ['foo.py']
Python 3.10.7 (main, Sep  8 2022, 14:34:29) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 

🟢 script, 🟢 arguments, 🚫 -exit

OpenROAD 🍧 ./build/src/openroad -python foo.py a b -c
OpenROAD v2.0-4990-gdf3add309 
This program is licensed under the BSD-3 license. See the LICENSE file for details.
Components of this program may be licensed under more restrictive licenses which must be honored.
[WARNING ORD-0039] .openroad ignored with -python
hello from openroad ['foo.py', 'a', 'b', '-c']
Python 3.10.7 (main, Sep  8 2022, 14:34:29) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 

🟢 script, 🚫 arguments, 🟢 -exit

OpenROAD 🍙 ./build/src/openroad -python foo.py -exit
OpenROAD v2.0-4990-gdf3add309 
This program is licensed under the BSD-3 license. See the LICENSE file for details.
Components of this program may be licensed under more restrictive licenses which must be honored.
[WARNING ORD-0039] .openroad ignored with -python
hello from openroad ['foo.py']

🟢 script, 🟢 arguments, 🟢 -exit

OpenROAD 🍙 ./build/src/openroad -python foo.py -exit
OpenROAD v2.0-4990-gdf3add309 
This program is licensed under the BSD-3 license. See the LICENSE file for details.
Components of this program may be licensed under more restrictive licenses which must be honored.
[WARNING ORD-0039] .openroad ignored with -python
hello from openroad ['foo.py']

proppy avatar Sep 22 '22 03:09 proppy

rebased, with DCO signature.

proppy avatar Sep 22 '22 03:09 proppy

Does the order of args matter ? For example: ./build/src/openroad -python foo.py -exit ./build/src/openroad -exit -python foo.py ./build/src/openroad -python -exit foo.py

maliberty avatar Sep 22 '22 03:09 maliberty

OpenROAD 🍫 ./build/src/openroad -python foo.py -exit
OpenROAD v2.0-4990-gdf3add309 
This program is licensed under the BSD-3 license. See the LICENSE file for details.
Components of this program may be licensed under more restrictive licenses which must be honored.
[WARNING ORD-0039] .openroad ignored with -python
hello from openroad ['foo.py']
OpenROAD 🍧 ./build/src/openroad -python -exit foo.py
OpenROAD v2.0-4990-gdf3add309 
This program is licensed under the BSD-3 license. See the LICENSE file for details.
Components of this program may be licensed under more restrictive licenses which must be honored.
[WARNING ORD-0039] .openroad ignored with -python
hello from openroad ['foo.py']
OpenROAD 🍙 ./build/src/openroad -exit -python foo.py
OpenROAD v2.0-4990-gdf3add309 
This program is licensed under the BSD-3 license. See the LICENSE file for details.
Components of this program may be licensed under more restrictive licenses which must be honored.
[WARNING ORD-0039] .openroad ignored with -python
hello from openroad ['foo.py']

proppy avatar Sep 22 '22 04:09 proppy

@tspyrou suggested that we add unittest to validate that openroad -python assumptions hold over time.

Most of the tests in https://github.com/The-OpenROAD-Project/OpenROAD/tree/master/test seems to be "design-oriented"; @maliberty is there already some test infrastructure to put up some functional test for the CLI? or should we create one?

proppy avatar Sep 27 '22 00:09 proppy

Define what a 'functional test' means to you. We have tests in every tool, the top level tests are system level tests.

maliberty avatar Sep 27 '22 01:09 maliberty

Define what a 'functional test' means to you

I test that would encode the behavior in https://github.com/The-OpenROAD-Project/OpenROAD/pull/2288#issuecomment-1254519937

proppy avatar Sep 27 '22 03:09 proppy

I don't think we need a whole infrastructure to test command line options. You can make a test like src/drt/test/gc_test.tcl that shells out

maliberty avatar Sep 27 '22 15:09 maliberty

Thanks for the reference! By infrastructure I mostly meant some test structure I can copy ;)

proppy avatar Sep 27 '22 16:09 proppy