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

Updated exit code for DRC regression #78

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mkkassem
Copy link
Collaborator

Fixes #<64>

@mkkassem mkkassem changed the title Updated exit code drc Updated exit code for DRC regression Nov 24, 2022

from sympy import arg
import pandas as pd
import logging

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@proppy That's a big change right now. We can move to it later.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

then can we file an issue to track that work?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@proppy Yes please do.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#79

t0 = time.time()
marker_gen = []
rules =[]
ly = 0
rules = []
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you make sure this follow https://peps.python.org/pep-0008/ ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@proppy Will check how we can change that

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@proppy Will take that into account.

name_ext = str(rule_deck_path).replace(".drc","").split("/")[-1]
os.system(f"mkdir run_{x}_{name_ext}")
check_call(f"mkdir run_{x}_{name_ext}", shell=True)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@proppy Will do.

name_ext = str(rule_deck_path).replace(".drc","").split("/")[-1]
os.system(f"mkdir run_{x}_{name_ext}")
check_call(f"mkdir run_{x}_{name_ext}", shell=True)

# Get the same rule deck with gds output
with open(rule_deck_path, 'r') as f:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this generating a file? curious if you've considering using a templating system like https://jinja.palletsprojects.com/ or a multi-line format string? That could help convey a better understanding of the final shape of the file to the reader.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@proppy No it's generating an output folder structure for testing.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to do a bit more than that: it reads rule_deck_path, then rewrite some of the line before appending them to marker_gen and then write the resulting strings to a file named markers.drc.

I'm curious why that rewriting is necessary (maybe add more comments), and if there is a better way (template?) to process this.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@proppy Yes, it generates a new rule deck from the original one and change the output to GDS layer rather than database output. For regression purposes.

Copy link
Member

@proppy proppy Nov 29, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can't this be a parameter passed to the rule deck using -rd rather than rewriting it on the fly?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@proppy No, that's a complicated thing to do. Also, the original rule deck doesn't need this output. It's only for regression purposes.

ly = 0
remove_if = False
ly = 0
remove_if = False

# Get the small rule deck with gds output
with open(rule_deck_path, 'r') as f:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

curious why you need to rewrite the drc file?

I think when @mithro suggested having smaller file, he suggested having them maintained in the repo as separate files, not created on the fly by the test script.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@proppy Because, the regression needs to change the output to generate polygons to be able to check if the output in the right location or not. Yes, I know that @mithro has suggested to split the files. I already have done that and I could publish them. But the run time will explode as I told @mithro. The expected run time for DRC unit tests would be around 25 hours alone. While now using this current technique is about 30 mins or so.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the regression needs to change the output to generate polygons to be able to check if the output in the right location or not.

Are those check dynamic (i.e: they need to be rewritten everytime you run the test because they depends on the input) or can they be static? if the later maybe you could simply have the rewritten rules as part of the repo test suite rather than regenerating them?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@proppy No they can't be static. Because assume you added a new rule or removed a rule how would you know.

os.system('mv -f {0}temp.log {0}{1}'.format(RUN_DIRECTORY,LOG_FILE_NAME))
check_call(
f'''
mkdir -p {RUN_DIRECTORY}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

couldn't you to this with the os module rather than doing it with commands?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@proppy will do.


if sw_failed:
logging.error("## One of the test cases failed. Exit with failure:")
print(df)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logging?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@proppy Not sure what's the question?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry for not being clear, should you use the logging module rather than raw print statement?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@proppy will change.

if sw_failed:
logging.error("## One of the test cases failed. Exit with failure:")
print(df)
exit(1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exception?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@proppy What's the difference? This will send a exit code of 1 which will fail github actions.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but an Exception give allow you to report more structured error and allow you to potentially handle it in the caller frames, i.e: imagine you have a test runner that run those test functions, you don't want the test itself to exit(1) (that would ends up the runner too as they are part of the same process) but you want to runner to be able to catch the Exception from the test and proceed accordingly.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@proppy But this is not a unit function. We only exit(1) after the entire run is complete.

else:
logging.info("## All test cases passed.")
logging.info("## All Switch checking patterns:")
print(df)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logging?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@proppy what's the difference?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logging gives you more control over the leveling of the log and allow you to optionally direct the output to a file, see https://docs.python.org/3/library/logging.html

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@proppy I got the point. Yes, that's why we use logging in the first place. The same comment as yours. But based on my experience printing Pandas DataFrame is nicer in print rather than logging. I could change it. But it won't be nice in the command line.

@@ -188,37 +186,38 @@ def main():
# Running DRC using klayout
if (arguments["--antenna_only"]) and not (arguments["--density_only"]):
logging.info(f"Running Global Foundries 180nm MCU antenna checks on design {name_clean} on cell {topcell_name}:")
os.system(f"klayout -b -r $PDK_ROOT/$PDK/gf180mcu_antenna.drc -rd input={path} -rd report={name_clean}_antenna_gf{arguments['--gf180mcu']}_gf{arguments['--gf180mcu']}.lyrdb -rd thr={thrCount} {switches}")
os.system(f"klayout -b -r {curr_path}/gf180mcu_antenna.drc -rd input={path} -rd report={name_clean}_antenna_gf{arguments['--gf180mcu']}_gf{arguments['--gf180mcu']}.lyrdb -rd thr={thrCount} {switches}")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

subprocess here and below?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@proppy will do.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@proppy This entire script will be rewriten. I got the idea of your requests.

@proppy
Copy link
Member

proppy commented Nov 25, 2022

did an first overview of the python scripts as requested by @atorkmabrains (/cc @mithro)

@mkkassem
Copy link
Collaborator Author

@atorkmabrains

1 similar comment
@mkkassem
Copy link
Collaborator Author

@atorkmabrains

@atorkmabrains
Copy link
Collaborator

@mkkassem I did answer all the questions and I'll make the necessary updates.

@proppy
Copy link
Member

proppy commented Nov 29, 2022

@atorkmabrains

@mkkassem I did answer all the questions

I still see some comments un-addressed, in https://github.com/google/globalfoundries-pdk-libs-gf180mcu_fd_pr/pull/78/files

and I'll make the necessary updates.

Please update this pull request w/ your changes, so that we can keep the review and the code changes in context.

@atorkmabrains
Copy link
Collaborator

@atorkmabrains I'll be working on it today and tomorrow.

proppy pushed a commit to proppy/globalfoundries-pdk-libs-gf180mcu_fd_pr that referenced this pull request Feb 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants