How to remove file from local pypi repository

I accidentally uploaded Python package (wheel and zip) to wrong repository. How to remove it?

Also, I can see two files with pulp python content list --filename file.zip but from the output is not clear which one in which repository. How to find this information?

To remove the content from the repository, run:
pulp python repository content remove --repository "$REPO_NAME" --filename "$FILENAME"

To identify which repository contains a specific file, first get the names of all Python repositories. Then, for each repository, retrieve its content PRNs and compare them with the PRN of the content you are interested in.

For example, if you are interested in the content with PRN prn:python.pythonpackagecontent:0197b042-905d-7da7-9e84-d79f398edaf0:

# Get the names of the repositories
pulp python repository list | jq -r ".[].name"
foo1
foo2

# Check which repository contains the desired content
pulp python repository content list --repository foo1 | jq -r ".[].prn"
prn:python.pythonpackagecontent:0197b078-4053-7556-90fc-ce542f07ebc7

pulp python repository content list --repository foo2 | jq -r ".[].prn"
prn:python.pythonpackagecontent:0197b042-905d-7da7-9e84-d79f398edaf0

Since the PRN appears in foo2, that is the repository you are looking for.

If you have more questions, I glad to help!

2 Likes

Thanks! I tried to use pulp python content but it doesn’t have remove action.

Looks like pulp python repository content remove ignores --repository option:

❯ pulp python repository content list --repository example | jq -r '.[].filename'                                
ml_services_utils-0.11.3.tar.gz
ml_services_utils-0.11.3-py3-none-any.whl

❯ pulp python repository content remove --repository example --filename ml_services_utils-0.11.3.tar.gz
Error: Multiple python packages found with {'filename': 'ml_services_utils-0.11.3.tar.gz'}.

I have it in another repository, this is correct.

It seems we have problem with our current cli implementation for removing content, we don’t handle duplicate filenames across multiple python content. We should fix that, but here is an example command of how to remove it manually, assuming you have the repository’s pulp_href and the content’s prn.

curl -X POST \
   -H "Authorization: Basic YWRtaW46cGFzc3dvcmQ=" \
   -H "Content-Type: application/json" \
   -d '{"remove_content_units":["prn:file.filecontent:01976052-63de-71df-ba48-224e607619e5"]}' \
   http://localhost:5001/pulp/api/v3/repositories/file/file/01976052-062a-7d07-b936-6eb924a870a2/modify/

# using httpie
http http://localhost:5001/pulp/api/v3/repositories/file/file/01976052-062a-7d07-b936-6eb924a870a2/modify/ \
    remove_content_units:='["prn:file.filecontent:01976052-63de-71df-ba48-224e607619e5"]'
2 Likes

Got it, thanks. Is it a bug in core or python plugin? Where should I fill a bug report?

In the cli repository: https://github.com/pulp/pulp-cli

1 Like