Git Product home page Git Product logo

Comments (6)

pac48 avatar pac48 commented on July 26, 2024 1

@peterdavidfagan Thanks for submitting the issue. There are two ways to go about adding this functionality. 1) modify the code generation logic and Python template or 2) try to make use of Python's flexibility to construct the dictionary dynamically. I would prefer option two if possible, that a method can simply be added to the Jinja template. The following implementation should work.

    def to_dict(self):
        out = {}

        def to_dict_internal(instance, base_name):
            if isinstance(instance, (str, numbers.Number, list)):
                out.update({base_name: instance})
            else:
                data = [attr for attr in dir(instance) if not callable(getattr(instance, attr)) and not attr.startswith("__") and attr is not "stamp_"]
                for attr in data:
                    to_dict_internal(getattr(instance, attr), ("" if base_name == "" else base_name + ".") + attr)

        to_dict_internal(self, "")

        return out

Unfortunately, I am not aware of a simpler way to achieve this. Plus, it is unclear if there is a missing edge case in filtering the output of the dir method. If you or anyone has a suggestion, I'd be interested to get feedback.

from generate_parameter_library.

pac48 avatar pac48 commented on July 26, 2024 1

@peterdavidfagan Awesome, that sounds like a good plan. I think it might be better to add the method to the Params (below this line ) class instead. That way, the syntax you proposed will work.

param_dict = param_listener.get_params().to_dict()

from generate_parameter_library.

peterdavidfagan avatar peterdavidfagan commented on July 26, 2024 1

That way, the syntax you proposed will work.

Makes sense, I'll hopefully get to this item before the end of this week.

from generate_parameter_library.

peterdavidfagan avatar peterdavidfagan commented on July 26, 2024 1

Hey @pac48,

I haven't opened pr yet as I did not finish these changes, but I have been meaning to follow up on this. Currently we are using the policy deployment code in our lab but have been reading yaml files directly via Python. At the moment, I am focused on completing a simulation env for a benchmark, in the new year I have a deadline for policy deployment baselines at which point I plan to update the moveit python library policy deployment code + tutorials. I will look to complete these changes when I am pushing this code.

from generate_parameter_library.

peterdavidfagan avatar peterdavidfagan commented on July 26, 2024

Thanks @pac48, I agree with your suggestion (2), this makes sense and thanks for sharing your code for this. I had started a similar method locally as a util, I'll look to combine this with your code and open a pull request with this method if this works for you?

I'll look to add the method to the ParamListener.

from generate_parameter_library.

pac48 avatar pac48 commented on July 26, 2024

@peterdavidfagan I just wanted to ping you about this request. If you were able to make the change feel free to open a PR.

from generate_parameter_library.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.