clean_channel
Functions:
Name | Description |
---|---|
clean_up_channel |
Clean up the package channel by sending DELETE requests to the delete api of the channel |
download_file |
Download a file (similar to wget) using urllib |
load_repodata |
Load the repodata.json file |
remove_version_matching_regex |
Remove packages matching a regex from the package collection |
select_package_to_delete |
Selects the packages to clean-up from a package collection based on rules inspired by gitlab's clean-up rules |
clean_up_channel
Clean up the package channel by sending DELETE requests to the delete api of the channel
Parameters:
Name | Type | Description | Default |
---|---|---|---|
packages_to_delete
|
PackageInfoCollection
|
Collections of package to delete in the channel. The packages filenames will be appended to the
|
required |
delete_api_url
|
str
|
API url to delete the packages. Eg: "https://prefix.dev/api/v1/delete/phoenix-dev/linux-64/" |
required |
api_token
|
str
|
Token to identify with the delete API. |
required |
timeout_s
|
int
|
timeout in seconds for the delete request. |
required |
Source code in src/phoenixpackagecleanup/clean_channel.py
download_file
Download a file (similar to wget) using urllib
The main reason we need this method is to download the repodata.json file. wget works out of the box, but when using urllib, we have to specify a User-agent otherwise the request is rejected (403: Forbidden)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
url
|
str
|
URL of the file to download |
required |
filepath
|
Path
|
Path to where the downloaded data will be written |
required |
user_agent
|
str
|
User-agent value to use in the request header |
required |
timeout_s
|
int
|
Timeout in second for the request |
required |
Source code in src/phoenixpackagecleanup/clean_channel.py
load_repodata
Load the repodata.json file
Parameters:
Name | Type | Description | Default |
---|---|---|---|
repodata_filepath
|
Path
|
Path to the repodata.json file |
required |
Returns:
Type | Description |
---|---|
ChannelPackages
|
Packages in the channel, grouped by package name |
Source code in src/phoenixpackagecleanup/clean_channel.py
remove_version_matching_regex
Remove packages matching a regex from the package collection
Parameters:
Name | Type | Description | Default |
---|---|---|---|
package_collection
|
PackageInfoCollection
|
Collection of packages to filter |
required |
Returns:
Type | Description |
---|---|
PackageInfoCollection
|
Collection of packages with the packages matching the regex removed |
Source code in src/phoenixpackagecleanup/clean_channel.py
select_package_to_delete
select_package_to_delete(channel_packages, current_time, delete_older_than_days, min_number_of_packages, keep_version_regex)
Selects the packages to clean-up from a package collection based on rules inspired by gitlab's clean-up rules
The selection rules work as the following:
- for each package name, get the list of package version/archives
- exclude the min_number_of_packages
most recent packages from the list
- exclude all packages that have been uploaded more recently than delete_older_than_days
days old.
- what remains in the list is selected for deletion
Parameters:
Name | Type | Description | Default |
---|---|---|---|
channel_packages
|
PackageInfoCollection
|
Collection of packages to clean-up. |
required |
current_time
|
datetime
|
The time at which the script is running, used to remove packages based on upload timestamp |
required |
delete_older_than_days
|
int
|
Packages which upload timestamp is less than |
required |
min_number_of_packages
|
int
|
Only if at least |
required |
keep_version_regex
|
str
|
regex applied to packages versions: if the package version match this, it will NOT be considered for deletion. |
required |
Returns:
Type | Description |
---|---|
PackageInfoCollection
|
Collection of packages that should be deleted to clean-up. |