Conversation
edwardcwang
left a comment
There was a problem hiding this comment.
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.
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.
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.
Yeah, maybe we can do that as a separate issue then?
There was a problem hiding this comment.
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.
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.
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
|
It seems like I broke something... |
edwardcwang
left a comment
There was a problem hiding this comment.
For type hinting comments, let's keep them proper
| """ | ||
| # 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 |
| 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 |
Co-Authored-By: edwardcwang <edwardcwang@users.noreply.github.com>
Co-Authored-By: edwardcwang <edwardcwang@users.noreply.github.com>
| """ | ||
| # 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.
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.
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.
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.