Skip to content
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

RSDK-8965: add subclasses to module generation #4491

Conversation

purplenicole730
Copy link
Member

@purplenicole730 purplenicole730 commented Oct 25, 2024

Jira Ticket

Add subclass parsing for the resources, namely board.

Flyby: reformatting some code

Testing done:

  • ran the test-module-generation workflow for the Python generation
  • generated/ran modules manually for Go generation
  • ask Rand to test out the binary

Python Example:

class MyModel(Board, EasyResource):
    MODEL: ClassVar[Model] = Model(ModelFamily("my-org", "my-module"), "my-model")

    ...

    class Analog(Board.Analog):

        async def read(
            self,
            *,
            extra: Optional[Dict[str, Any]] = None,
            timeout: Optional[float] = None,
            **kwargs
        ) -> Board.Analog.Value:
            raise NotImplementedError()

        async def write(
            self,
            value: int,
            *,
            extra: Optional[Dict[str, Any]] = None,
            timeout: Optional[float] = None,
            **kwargs
        ):
            raise NotImplementedError()

Go Example:

type analogClient struct {
	*myModuleMyModel
	boardName  string
	analogName string
}

func (s *analogClient) Read(ctx context.Context, extra map[string]interface{}) (board.AnalogValue, error) {
	panic("not implemented")
}

func (s *analogClient) Write(ctx context.Context, value int, extra map[string]interface{}) error {
	panic("not implemented")
}

@viambot viambot added the safe to test This pull request is marked safe to test from a trusted zone label Oct 25, 2024
@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Oct 28, 2024
@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Oct 28, 2024
@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Oct 28, 2024
@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Oct 28, 2024
@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Oct 28, 2024
@purplenicole730 purplenicole730 marked this pull request as ready for review October 28, 2024 17:12
@purplenicole730 purplenicole730 requested review from a team, stuqdog and jckras and removed request for a team October 28, 2024 17:12
@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Oct 28, 2024
@viambot viambot removed the safe to test This pull request is marked safe to test from a trusted zone label Oct 28, 2024
@viambot viambot added the safe to test This pull request is marked safe to test from a trusted zone label Oct 28, 2024
@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Oct 28, 2024
@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Oct 28, 2024
@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Oct 28, 2024
@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Oct 28, 2024
Copy link
Member

@jckras jckras left a comment

Choose a reason for hiding this comment

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

I left a few questions and some optional changes for readability but otherwise LGTM!

cli/module_generate/scripts/generate_stubs.go Outdated Show resolved Hide resolved
cli/module_generate/scripts/generate_stubs.go Show resolved Hide resolved
cli/module_generate/scripts/generate_stubs.py Show resolved Hide resolved
cli/module_generate/scripts/generate_stubs.go Outdated Show resolved Hide resolved
cli/module_generate/scripts/generate_stubs.py Show resolved Hide resolved
cli/module_generate/scripts/generate_stubs.py Show resolved Hide resolved
@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Oct 29, 2024
Copy link
Member

@stuqdog stuqdog left a comment

Choose a reason for hiding this comment

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

One minor thing and we should figure out why the tests are failing, otherwise lgtm!

cli/module_generate/scripts/generate_stubs.go Show resolved Hide resolved
@purplenicole730
Copy link
Member Author

The tests failing doesn't seem to be related to this PR, as other PRs are also failing these two tests (Go 32-bit and Mac build)

@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Oct 31, 2024
@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Oct 31, 2024
@purplenicole730 purplenicole730 merged commit 5b26371 into viamrobotics:main Oct 31, 2024
18 checks passed
@purplenicole730 purplenicole730 deleted the RSDK-8965-add-subclasses-to-module-generation branch October 31, 2024 17:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
safe to test This pull request is marked safe to test from a trusted zone
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants