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

[Build] Generate traits rather than hard-code them #15

Merged
merged 5 commits into from
Dec 1, 2022

Conversation

elliotcmorris
Copy link
Contributor

@elliotcmorris elliotcmorris commented Nov 25, 2022

Closes #10

Remove hand rolled traits, and replace them with generated ones via openassetio-traitgen integration.
This is so we can avoid having to manually write and maintain custom traits, as it's too much of a maintenance burden.

This effectively unlocks further integration of mediacreation into other integrations, as traits can now be trivially added if neccesary.

Testing

The hand rolled traits had a minimal set of tests, these have been removed in favour of import tests, as we trust the traits coming out of traitgen, and we don't want to roll tests for every generated trait.
However, prior to removal, these tests were run against the generated traits, (you can see the tests were only removed in the final commit,) to verify that the traits exhibited the same behaviour before and after the swap over.

As this is a first time merge of CI cross-repo, please find the action runs on this PR targetting my fork :
elliotcmorris#2

@elliotcmorris elliotcmorris self-assigned this Nov 25, 2022
@elliotcmorris elliotcmorris marked this pull request as ready for review November 25, 2022 12:16
@elliotcmorris elliotcmorris marked this pull request as draft November 25, 2022 12:17
@elliotcmorris elliotcmorris marked this pull request as ready for review November 25, 2022 12:29
@foundrytom
Copy link
Contributor

foundrytom commented Nov 25, 2022

@elliotcmorris we can delete the test code other than import checks - we went with being happy that traitgen itself is sufficiently tested. Sorry just saw they were deleted in a subsequent commit. I just confoozed myself seeing the diff updating them.

Copy link
Contributor

@foundrytom foundrytom left a comment

Choose a reason for hiding this comment

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

Sorry not the most comprehensive of reviews (hopefully @feltech will be able to apply his usual 🦅 👁️ ), but looks great to me, nice one! Love how simple it is to get generation working in setup.py. Good job remembering to update README.md too! 👍

Mostly minor pedant notes.

RELEASE_NOTES.md Outdated Show resolved Hide resolved
setup.py Outdated Show resolved Hide resolved
RELEASE_NOTES.md Outdated Show resolved Hide resolved
RELEASE_NOTES.md Show resolved Hide resolved
Copy link
Member

@feltech feltech left a comment

Choose a reason for hiding this comment

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

Looks good, all minor stuff.

setup.py Show resolved Hide resolved
traits.yml Outdated Show resolved Hide resolved
traits.yml Outdated Show resolved Hide resolved
traits.yml Outdated Show resolved Hide resolved
RELEASE_NOTES.md Show resolved Hide resolved
setup.py Show resolved Hide resolved
Copy link
Contributor

@foundrytom foundrytom left a comment

Choose a reason for hiding this comment

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

(testenv)  OpenAssetIO-MediaCreation (work/10-gen-traits) ✗ python -m pip install .
Processing /Users/tomcowland/dev/OpenAssetIO-MediaCreation
  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  ERROR: Command errored out with exit status 1:
...
  Complete output (14 lines):
  error: Multiple top-level packages discovered in a flat-layout: ['ignoreme', 'decisions'].

@foundrytom
Copy link
Contributor

foundrytom commented Nov 30, 2022

[fix] Its no longer generating content traits, looks like the re-tabbing has left that dict with an extra indent level. Can we make sure we double check the CI run in the other org before merging this?

@foundrytom
Copy link
Contributor

@elliotcmorris I've attempted to adjust the approval settings for actions here (as they don't behave as their docs say, for some reason), so maybe they'll run on the next push.

@elliotcmorris
Copy link
Contributor Author

Annoying that that happened, as I installed an autoformatter to do the indentation for me, (just the redhat one that had a code extension.) I'm guessing that we don't have a yaml formatter standard as of yet.

@elliotcmorris
Copy link
Contributor Author

@feltech @foundrytom

It looks like we are gonna have to do the .gitkeep/readme in an empty dir approach, explicitly defining a package (to solve the issue of it thinking decisions was the project dir,) does fail when there isn't a directory of that name in place, as we suspected.

Was wondering thoughts on doing packages in pyproject.toml vs setup.py, as pip 22 does warn

Support for `[tool.setuptools]` in `pyproject.toml` is still *beta*.

I think it's fine, this is clearly the way the wind is blowing.

@foundrytom
Copy link
Contributor

@feltech @foundrytom

It looks like we are gonna have to do the .gitkeep/readme in an empty dir approach, explicitly defining a package (to solve the issue of it thinking decisions was the project dir,) does fail when there isn't a directory of that name in place, as we suspected.

Thanks for checking, I liked your README.md idea as it helps people work out how it actually works!

Was wondering thoughts on doing packages in pyproject.toml vs setup.py, as pip 22 does warn

Support for `[tool.setuptools]` in `pyproject.toml` is still *beta*.

I think it's fine, this is clearly the way the wind is blowing.

I'd be happy with that too, as were still in alpha.

@elliotcmorris
Copy link
Contributor Author

@foundrytom @feltech
Ready for re-review, two fixups based on the issues we found
#1 elliotcmorris@95c5cd9 - Fix indentation error causing trait not to be generated
#2 elliotcmorris@7ddce56 - Add empty openassetio_mediacreation module folder, to avoid setuptools thinking decisions is the module.

CI passes on fork

Copy link
Contributor

@foundrytom foundrytom left a comment

Choose a reason for hiding this comment

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

Nice one @elliotcmorris LGTM

Copy link
Member

@feltech feltech left a comment

Choose a reason for hiding this comment

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

Minor notes, otherwise LGTM

openassetio_mediacreation/README.md Outdated Show resolved Hide resolved
openassetio_mediacreation/README.md Show resolved Hide resolved
Rather than have manually maintained traits, integrate traitgen to
generate the traits automatically in the build.

Issue #10

Signed-off-by: Elliot Morris <elliot.morris@foundry.com>
Add import tests to mediacreation, to check that the generated traits
function.

Issue #10

Signed-off-by: Elliot Morris <elliot.morris@foundry.com>
Run pytest on PRs, so we can have some CI going.

Issue #10

Signed-off-by: Elliot Morris <elliot.morris@foundry.com>
Remove the tests that were testing the manually rolled traits.
Now that the traits are autogenerated, we rely on the tests in
openassetio-traitgen

Issue #10

Signed-off-by: Elliot Morris <elliot.morris@foundry.com>
Add information about the new traitgen approach to the readme.

Signed-off-by: Elliot Morris <elliot.morris@foundry.com>
@elliotcmorris elliotcmorris merged commit 0280442 into OpenAssetIO:main Dec 1, 2022

# Move the source trait yaml to the package directory.
copyfile(
"traits.yml", os.path.join(self.build_lib, "openassetio_mediacreation", "traits.yml")

Choose a reason for hiding this comment

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

This should be handled as package data. See https://setuptools.pypa.io/en/latest/userguide/datafiles.html

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We logged an issue for this : #16

We did a short initial investigation, to see if it would "just work," but unfortunately the install was running into trouble identifying package data, I suspect related to the problems we were seeing around setuptools not figuring as as a full "package" due to generating after the fact.

But we didn't dig very far, are planning to go back later and get to it properly.

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.

Switch MC to using openassetio-traitgen
4 participants