-
Notifications
You must be signed in to change notification settings - Fork 6
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
Remove deprecated reparse_args usage #199
Conversation
The example code that you fixed up is a little problematic still because it doesn't add any agent-specific command-line args. (--port would be a good one for demo.) The documentation in https://ocs.readthedocs.io/en/develop/developer/site_config.html#agent-site-related-command-line-parameters is pretty good, but it is not linked from the Developers:Agents section... it should be. The now-deprecated sequence is:
and that should be pretty close to the same thing as:
(Assuming of course that make_parser() can indeed make its own parser; otherwise pass in a new ArgumentParser().) Were there SOCS agents using it in a weird way? site_config.parse_args() seems suitable for agents but it is a little problematic for non-agents, such as clients and ocsbow... I think I have a fix for ocsbow at least; let me know if I should add it here or submit separately. |
Right, good point. Since the example in the docs uses the long unused HWP Simulator Agent that doesn't add any arguments I thought I'd swap it out for a perhaps more familiar example, the FakeDataAgent. I've done that, and replaced instances of full file insertions with
Ah, great, didn't realize that was there, it's now linked. Updated in 347d305.
I don't think so, it was just me trying to update it without knowing the full replacement, leaving behind an
I'd say a fix for ocsbow could be separate. |
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.
Sorry to sleep on this, if you were waiting for me. This is a draft PR but I guess it's ready to go? This looks good to me.
347d305
to
538b30d
Compare
Thanks. I think I stalled out here when trying to write some tests for the behavior I thought I was trying to avoid. Going to go ahead with the merge now though after a rebase. |
Description
site_config.reparse_args()
has been deprecated for a while now, but is still very widely used in socs Agents. This removes it from the only core agent still using it, from one of the examples, and perhaps mostly importantly from the Agent developer documentation.The one place I haven't removed it from is from ocsbow. I was finding in removing it from some socs Agents that if the Agent still called this line:
to initialize the parser, when
site_config.parse_args()
was later called (which internally callssite_config.add_arguments()
) we get a conflict error from argparse. Maybe we can discuss how this should be handled here? This PR at least updates examples that might get copied as new Agents are developed. Then an issue can be created if we don't end up handling howadd_arguments()
interacts with things.Motivation and Context
It's common for new Agents to start from copies of older Agents. This results in the deprecated
reparse_args
being used regularly in new code. Just trying to get things up to date.How Has This Been Tested?
I've tested that style of change on other Agents, though really I should test these Agents too. I will open this as draft until those are done (likely early next week.)
Types of changes
Checklist:
develop
branch.