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

Replace conflicting repository-service-tuf dep #16098

Merged
merged 4 commits into from
Jun 14, 2024

Conversation

lukpueh
Copy link
Contributor

@lukpueh lukpueh commented Jun 13, 2024

Previously, repository-service-tuf (i.e. the RSTUF cli) was used to bootstrap an RSTUF repo for development. This PR re-implements the relevant parts of the cli locally in Warehouse and removes the repository-service-tuf dependency, which conflicts with other dependencies.

Change details

supersedes #15958 (cc @facutuesca @woodruffw)

@lukpueh lukpueh requested a review from a team as a code owner June 13, 2024 14:00
Copy link
Member

Choose a reason for hiding this comment

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

Code looks fine, but an organization question: are these functions going to be used outside of the cli.tuf module? If not IMO we could inline them there.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I plan to use the same "RSTUF API library" to "add targets", i.e. tell rstuf to update tuf metadata. See #15815

return resp_data["task_id"]


def wait_for_success(server: str, task_id: str):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@woodruffw, in case you are familiar with warehouse's async task machinery, do you think it's worth to make this a task, which calls retry() until "SUCCESS" or max retry instead of looping?

I thought it might be more elegant, but I didn't get it to work (I'm pretty unfamiliar with Celery).

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, this could probably be done with a custom celery.Task, although it's been a few years since I've mucked around in Celery 🙂

IMO this is fine as is, although longer term either a Celery task integration or a synchronous wrapper would be ideal.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess I'll leave it as is. My plan for #15815 is to already make the calling function (update_metadata) an async task, which blocks on wait_for_success. So making the latter async as well, maybe isn't helpful. But I'll let the Warehouse maintainers comment.

Thanks for taking a look!

@lukpueh
Copy link
Contributor Author

lukpueh commented Jun 14, 2024

Just pushed some tests. Coverage passes now. Please take another look.

Copy link
Member

@woodruffw woodruffw left a comment

Choose a reason for hiding this comment

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

LGTM! CC @facutuesca for a review as well, to confirm that this handles the dep issue sufficiently 🙂

@woodruffw
Copy link
Member

(This will need a rebase/fast-forward onto main for a merge.)

@facutuesca
Copy link
Contributor

LGTM! CC @facutuesca for a review as well, to confirm that this handles the dep issue sufficiently 🙂

Yes, this fixes it. Thanks @lukpueh !!

lukpueh added 4 commits June 14, 2024 19:37
Previously, `repository-service-tuf` (i.e. the RSTUF cli) was used to
bootstrap an RSTUF repo for development. This PR re-implements the
relevant parts of the cli locally in Warehouse and removes the
`repository-service-tuf` dependency, which conflicts with other
dependencies.

Change details
- Add lightweight RSTUF API client library (can be re-used for pypi#15815)
- Add local `warehouse tuf bootstrap` cli subcommand, to wraps lib calls
- Invoke local cli via `make inittuf`
- Remove dependency

supersedes pypi#15958 (cc @facutuesca @woodruffw)

Signed-off-by: Lukas Puehringer <[email protected]>
Other than the regular click File, the LazyFile also has the "name"
attribute, when passing stdin via "-".

We print the name on success.

Signed-off-by: Lukas Puehringer <[email protected]>
@lukpueh lukpueh force-pushed the tmp-rm-rstuf-cli branch from 0acb331 to 36b861c Compare June 14, 2024 17:37
import click

from warehouse.cli import warehouse
from warehouse.tuf import post_bootstrap, wait_for_success
Copy link
Member

Choose a reason for hiding this comment

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

In other CLI modules, we move the imports to the command that uses them, often with this comment, so that the CLI startup time is pretty lean.

    # Imported here because we don't want to trigger an import from anything
    # but warehouse.cli at the module scope.

Looking at warehouse.tuf, it doesn't currently import anything that I'm particularly worried will be slow, so happy to defer that until there's more, but wanted to highlight it.

@miketheman miketheman merged commit 95949f1 into pypi:main Jun 14, 2024
17 checks passed
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