-
Notifications
You must be signed in to change notification settings - Fork 60
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
Mode enum #407
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution! I left a comment below about this enum.
Empty = 2 | ||
Manual = 3 | ||
Generate = 4 | ||
Generated = 5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I'm aware, the modes we use are:
Auto = 1
Empty = 2
Manual = 3
Generated = 4
append
, prepend
are part of another part of Hammer and not part of this mode enum.
Also, if we are going to create this enum, I think it may be good to also use them in some of the settings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should change power straps to generated
from generate
if we're going to use generate
. I personally like generate
better, but generated
does keep all of the modes as adjectives, which also makes sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, maybe we can do that as a separate issue then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can just tack it on to #397 .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Edward, thanks for your comment! I checked defaults.yml and it seems that pin place mode uses generated
, and power straps mode uses generate
. Just to make sure, they are the same and we'll stick with generate
, right?
Also, I'm not sure what it means to use the enum in the settings, could you explain a bit more?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Jingyi- let's use generated
instead of generate
. We'll change the power straps mode to generate
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, so John's comment above is alluding to that problem. I think the desired action is to use generated
and just ignore the power straps mode for now.
As for use, if you look in the code, right now it uses strings - the intention is to use this enum instead
if bumps_mode == "empty": |
It seems like I broke something... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For type hinting comments, let's keep them proper
@@ -970,7 +973,7 @@ def get_gds_map_file(self) -> Optional[str]: | |||
:return: Fully-resolved path to GDS map file or None. | |||
""" | |||
# Mode can be auto, empty, or manual | |||
gds_map_mode = str(self.get_setting("par.inputs.gds_map_mode")) # type: str | |||
gds_map_mode = ModeType.from_str(str(self.get_setting("par.inputs.gds_map_mode"))) # type: ModeType Enum |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
@@ -1323,15 +1323,15 @@ def generate_power_spec_commands(self) -> List[str]: | |||
return [] | |||
|
|||
power_spec_contents = "" # type: str | |||
power_spec_mode = str(self.get_setting("vlsi.inputs.power_spec_mode")) # type: str | |||
if power_spec_mode == "empty": | |||
power_spec_mode = ModeType.from_str(str(self.get_setting("vlsi.inputs.power_spec_mode"))) # type: ModeType Enum |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
Co-Authored-By: edwardcwang <[email protected]>
Co-Authored-By: edwardcwang <[email protected]>
@@ -970,7 +973,7 @@ def get_gds_map_file(self) -> Optional[str]: | |||
:return: Fully-resolved path to GDS map file or None. | |||
""" | |||
# Mode can be auto, empty, or manual | |||
gds_map_mode = str(self.get_setting("par.inputs.gds_map_mode")) # type: str | |||
gds_map_mode = ModeType.from_str(str(self.get_setting("par.inputs.gds_map_mode"))) # type: ModeType |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We may want to create a static helper method called ModeType.from_setting
that takes the HammerTool
object and the setting string as args and returns a ModeType
. e.g.
class ModeType:
@staticmethod
def from_setting(tool: HammerTool, setting: str) -> ModeType:
return ModeType.from_str(str(tool.get_setting(setting)))
which would then allow the following change (no need for type hint, either):
gds_map_mode = ModeType.from_str(str(self.get_setting("par.inputs.gds_map_mode"))) # type: ModeType | |
gds_map_mode = ModeType.from_setting(self, "par.inputs.gds_map_mode") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not to nitpick too much - at that point I would prefer almost gds_map_mode = self.get_mode_setting("par.inputs.gds_map_mode")
to avoid a dependency from ModeType
-> HammerTool
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also like that, perhaps more.
Sorry for introducing bugs. The errors in the unit tests are
Is it potentially because I was not importing properly? |
Hi Jingyi- you can run the unittests in src/test/unittests.sh: https://github.com/ucb-bar/hammer/blob/master/src/test/unittests.sh |
Issue: #400
I was not entirely sure where to put the mode enum class so I put it in hammer_tool.py. I can move it if there is a better place.
I will modify the string comparisons and open another PR if this enum class looks good.