Skip to content

Conversation

@jeffiuliano
Copy link
Collaborator

One typo fix, two suggestions.

  1. added subs property of a component so you can, instead of eg switch1.get_all_subcomponents() write
In [5]: switch1.subs
Out[5]: 
[component ethernet-port: switch-wiz6-snABC_p04 (4192),
 component ethernet-port: switch-wiz6-snABC_p00 (8360),
 component ethernet-port: switch-wiz6-snABC_p02 (16552),
 component ethernet-port: switch-wiz6-snABC_p01 (40972360),
 component ethernet-port: switch-wiz6-snABC_p05 (40980488),
 component ethernet-port: switch-wiz6-snABC_p03 (81936464)]
  1. Made ComponentType instances callable (by adding __call__ fn to the class definition). This allows:
In [2]: t_switch           = ComponentType("switch", "a network switch").add()
ComponentType with name switch already exists in the database.

In [4]: switch1  = t_switch("switch-wiz-snABC").add()
Component with name switch-wiz-snABC already exists in the database.

instead of

In [3]: switch1  = Component("switch-wiz-snABC", t_switch).add()
Component with name switch-wiz-snABC already exists in the database.

@jeffiuliano jeffiuliano requested a review from ahincks February 22, 2023 20:31
@ahincks
Copy link
Contributor

ahincks commented Jun 22, 2023

I'm not sure I'm sold on making the class callable. For ComponentType it currently seem benign, but presumably we'd want to make other classes callable too, and for some other classes it would be problematic. E.g., if Component were callable, it would probably break things if you started doing operations on the object before it had actually been added to the DB.

I'm not necessarily opposed to the subs property, but is it mainly to make the call less verbose? I'd certainly be in favour of shortening some of the method names which are too long. I.e., would you be OK with shortening the method to subcomponents() or subcomps() or similar? Or is there a need to additionally have a property?

@ahincks
Copy link
Contributor

ahincks commented Jun 22, 2023

(Also, sorry for taking so long to finally comment …)

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.

3 participants