Skip to content

Conversation

mkundu1
Copy link
Contributor

@mkundu1 mkundu1 commented May 13, 2022

No description provided.

)
self.solver = Session.Solver(
self._datamodel_service_tui, self._settings_service
self._datamodel_service_tui, self.get_settings_service()
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would prefer if codegen called _get_settings_service() so that the method would be identified as private for library users. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, we don't need to expose the services from the session object. Actually the codegen can just use the private attribute session._settings_service.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah, we don't need to expose the services from the session object. Actually the codegen can just use the private attribute session._settings_service.

Great, I'll approve on that basis. Thanks.

@mkundu1 mkundu1 changed the title Add back get_settings_service Update codegen for API restructuring May 13, 2022

session = launch_fluent()
sinfo = session.get_settings_service().get_static_info()
sinfo = session._settings_service.get_static_info()
Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't this give a warning about access to a protected member from outside the class?

Copy link
Collaborator

Choose a reason for hiding this comment

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

It's got past all the style checks.

Copy link
Contributor

Choose a reason for hiding this comment

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

That is because we skip style checks for the settings directory. But from a maintainer of the session class point of view, I would assume that _settings_service is not being used outside my class.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Another option would be for the codegen code to have a class derived from Session with a public method that invokes the protected one.

Copy link
Contributor

Choose a reason for hiding this comment

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

What is the concern in having get_settings_service() as a public method?

Copy link
Collaborator

Choose a reason for hiding this comment

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

My assumption was that it was redundant as a member of the public API. Is that wrong? I didn't look into it, but assumed.

Copy link
Contributor Author

@mkundu1 mkundu1 May 13, 2022

Choose a reason for hiding this comment

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

I feel if we decide to expose the services from the session instance as public API (for consumption by pyfluent users), we should do that uniformly for all services.

I think the session class's maintainer's responsibility is upto marking the members appropriately as public or non-public and documenting the public API. The client code is responsible for the usage of the non-public API and if the client code breaks when that part of the API is changed unannounced (https://docs.python-guide.org/writing/style/#we-are-all-responsible-users). In the current case, the client code is used by developers and is not packaged for users, so I think usage of the non-public API is ok. If we decide to make codegen module more public in future, we can expose the services from session instance, or the codegen module can directly use the classes like SettingsService from the services module.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Fwiw that’s where I’m at on this one

@mkundu1 mkundu1 merged commit 18b59e5 into main May 13, 2022
@mkundu1 mkundu1 deleted the bug/get_settings_service branch May 13, 2022 17:14
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.

5 participants