Skip to content

Commit c6335c2

Browse files
daveoconnorkarimarie67
authored andcommitted
Updated import commands to allow and default to 'new' functionality. Remove artifactory-related commands. (boostorg#1744)
1 parent a61c8d7 commit c6335c2

File tree

12 files changed

+125
-134
lines changed

12 files changed

+125
-134
lines changed

docs/commands.md

Lines changed: 16 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
- [`boost_setup`](#boost_setup)
55
- [`import_versions`](#import_versions)
66
- [`import_archives_release_data`](#import_archives_release_data)
7-
- [`import_artifactory_release_data`](#import_artifactory_release_data)
87
- [`update_libraries`](#update_libraries)
98
- [`import_library_versions`](#import_library_versions)
109
- [`import_library_version_docs_urls`](#import_library_version_docs_urls)
@@ -49,16 +48,16 @@ Imports `Version` objects from GitHub.
4948

5049
**Options**
5150

52-
| Options | Format | Description |
53-
|----------------------|--------|--------------------------------------------------------------|
54-
| `--delete-versions` | bool | If passed, will delete all Version objects before importing Versions. |
55-
| `--new` | bool | If passed, will import only new Version objects. |
56-
| `--token` | string | GitHub API Token. If passed, will use this value. If not passed, will use the value in settings. |
51+
| Options | Format | Description |
52+
|----------------------|--------|---------------------------------------------------------------------------------------------------------|
53+
| `--delete-versions` | bool | If passed, will delete all Version objects before importing Versions. |
54+
| `--new` | bool | Default: 'true'. If 'true', will import only new Version objects. Set to 'false' to import all versions |
55+
| `--token` | string | GitHub API Token. If passed, will use this value. If not passed, will use the value in settings. |
5756

5857
**Process**
5958

6059
- Retrieves the tags for the GitHub repo in `BASE_GITHUB_URL`
61-
- Loops through all tags, and discards any that do not match our inclusion logic
60+
- Loops through all tags, and discards any that do not match our inclusion logic, by default only versions that haven't already been imported.
6261
- For each successful tag, import it as a `Version` object
6362
- Then, run the command to the release downloads from Artifactory as `VersionFile` objects
6463

@@ -76,40 +75,16 @@ Import `VersionFile` objects from Artifactory.
7675

7776
**Options**
7877

79-
| Options | Format | Description |
80-
|----------------------|--------|--------------------------------------------------------------|
81-
| `--release` | string | Format: `boost-1.63.0`. If passed, will import Archive urls for only that version. |
78+
| Options | Format | Description |
79+
|------------|--------|------------------------------------------------------------------------------------------------------------------------------|
80+
| `--new` | bool | Default: 'true'. If 'true', will import only the newest release data. Set to 'false' to import archive data for all releases |
81+
| `--release` | string | Format: `boost-1.63.0`. If passed, will import Archive urls for only that release. Overrides --new |
8282

8383
**More Information**
8484

85-
- Loops through `Version` objects and calls the task that retrieves the Archives data with the version information
85+
- Loops through `Version` objects, by default only the most recent one, and calls the task that retrieves the Archives data with the version information
8686
- Saves the Archives JSON data as `VersionFile` objects
8787

88-
89-
## `import_artifactory_release_data`
90-
91-
*This process was run automatically as part of `import_versions`, but has been replaced by `import_archives_release_data`.*
92-
93-
Import `VersionFile` objects from Artifactory.
94-
95-
**Example**
96-
97-
```bash
98-
./manage.py import_artifactory_release_data
99-
```
100-
101-
**Options**
102-
103-
| Options | Format | Description |
104-
|----------------------|--------|--------------------------------------------------------------|
105-
| `--release` | string | Format: `boost-1.63.0`. If passed, will import Artifactory urls for only that version. |
106-
107-
**More Information**
108-
109-
- Loops through `Version` objects and calls the task that retrieves the Artifactory data with the version information
110-
- Saves the Artifactory data as `VersionFile` objects
111-
112-
11388
## `update_libraries`
11489

11590
**Purpose**: Import and update `Library` and `Category` objects. Runs the library update script, which cycles through the repos listed in the Boost library and syncs their information. Most library information comes from `meta/libraries.json` stored in each Boost library repo.
@@ -138,14 +113,15 @@ Import `VersionFile` objects from Artifactory.
138113

139114
**Options**
140115

141-
| Options | Format | Description |
142-
|----------------------|--------|--------------------------------------------------------------|
143-
| `--token` | string | GitHub API Token. If passed, will use this value. If not passed, will use the value in settings. |
116+
| Options | Format | Description |
117+
|----------------------|--------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
118+
| `--token` | string | GitHub API Token. If passed, will use this value. If not passed, will use the value in settings. |
144119
| `--release` | string | Format: `boost-1.63.0`. If passed, will import Artifactory urls for only that version. Partial versions are accepted (so "1.7" will import libraries for version 1.70.0, 1.71.0, etc.) |
120+
| `--new` | bool | Default: 'true'. If 'true', will import data for the newest release. Set to 'false' to import library version data for all releases |
145121

146122
**Process**
147123

148-
- Loops through `Version` objects based on passed-in options
124+
- Loops through `Version` objects based on passed-in options, by default just the most recent one.
149125
- For each `Version`, gets the libraries in that release from the `.gitmodules` file using the GitHub API
150126
- For each library listed in the `.gitmodules` file, get the complete list of libraries from the library's `meta/libraries.json` file (in its GitHub repo) using the GitHub API. (A single library repo might contain information for multiple libraries. Example: Functional also hosts Functional/Factory).
151127
- Save the `LibraryVersion` objects

docs/release_downloads.md

Lines changed: 0 additions & 12 deletions
This file was deleted.

libraries/management/commands/import_library_version_docs_urls.py

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,24 @@
99

1010
@click.command()
1111
@click.option(
12-
"--version",
12+
"--release",
1313
help="Boost version number (example: 1.81.0). If a partial version number is "
1414
"provided, the command process all versions that contain the partial version "
1515
"number (example: '--version='1.7' would process 1.7.0, 1.7.1, 1.7.2, etc.)",
1616
)
17+
@click.option(
18+
"--new",
19+
default=True,
20+
type=click.BOOL,
21+
help="True (default) Import library docs for newest version only from the db. False"
22+
" downloads docs for all versions",
23+
)
1724
@click.option(
1825
"--min-version",
1926
default=settings.MINIMUM_BOOST_VERSION,
2027
help="Minimum Boost version to process (default: 1.30.0)",
2128
)
22-
def command(version: str, min_version: str):
29+
def command(release: str, new: bool, min_version: str):
2330
"""Cycles through all Versions in the database, and for each version gets the
2431
corresponding tag's .gitmodules.
2532
@@ -28,40 +35,44 @@ def command(version: str, min_version: str):
2835
add maintainers to LibraryVersions.
2936
3037
Args:
31-
version (str): Boost version number (example: 1.81.0). If a partial version
38+
release (str): Boost version number (example: 1.81.0). If a partial version
3239
number is provided, the command process all versions that contain the
3340
partial version number (example: "--version="1.7" would process 1.70.0,
3441
1.70.1, 1.71.0, etc.)
42+
new (bool): If True (default), only imports library docs for the most recent
43+
version, if False it processes all versions greater than or equal to
44+
min_version. Overridden by --release if provided.
3545
min_version (str): Minimum Boost version to process. If this is passed, then
3646
only versions that are greater than or equal to this version will be
3747
processed.
3848
"""
3949
click.secho("Saving links to version-specific library docs...", fg="green")
4050
min_version = f"boost-{min_version}"
41-
if version is None:
42-
versions = Version.objects.active().filter(name__gte=min_version)
51+
version_qs = Version.objects.active().filter(name__gte=min_version)
52+
if release:
53+
versions = Version.objects.filter(name__icontains=release).order_by("-name")
54+
elif new:
55+
versions = [Version.objects.most_recent()]
4356
else:
44-
versions = Version.objects.filter(
45-
name__icontains=version, name__gte=min_version
46-
)
57+
versions = version_qs.order_by("-name")
4758

4859
# For each version, get the library version documentation url paths
49-
for version in versions.order_by("-name"):
50-
click.echo(f"Processing version {version.name}...")
60+
for release in versions:
61+
click.echo(f"Processing version {release.name}...")
5162
try:
52-
get_and_store_library_version_documentation_urls_for_version(version.pk)
63+
get_and_store_library_version_documentation_urls_for_version(release.pk)
5364
except ValueError as e:
5465
click.secho(e, fg="red")
5566
continue
5667

57-
for version in versions.order_by("-name"):
58-
library_versions = LibraryVersion.objects.filter(version=version)
59-
click.secho(f"Processing version {version.name}...", fg="green")
68+
for release in versions:
69+
library_versions = LibraryVersion.objects.filter(version=release)
70+
click.secho(f"Processing version {release.name}...", fg="green")
6071
for library_version in library_versions:
6172
if not library_version.documentation_url:
6273
click.secho(
6374
f"Could not get docs url for {library_version.library.name} "
64-
f"({version.name}).",
75+
f"({release.name}).",
6576
fg="red",
6677
)
6778
continue

libraries/management/commands/import_library_versions.py

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,20 @@
99
@click.command()
1010
@click.option("--token", help="Github API token")
1111
@click.option("--release", help="Boost version number (example: 1.81.0)")
12+
@click.option(
13+
"--new",
14+
default=True,
15+
type=click.BOOL,
16+
help="Update only the library versions for the most recent version (default: True)."
17+
" False processes library versions for all versions greater than or equal to"
18+
" min-release.",
19+
)
1220
@click.option(
1321
"--min-release",
1422
default=settings.MINIMUM_BOOST_VERSION,
1523
help="Minimum Boost version to process (default: 1.31.0)",
1624
)
17-
def command(min_release: str, release: str, token: str):
25+
def command(min_release: str, release: str, new: bool, token: str):
1826
"""Cycles through all Versions in the database, and for each version gets the
1927
corresponding tag's .gitmodules.
2028
@@ -30,18 +38,22 @@ def command(min_release: str, release: str, token: str):
3038
number is provided, the command process all versions that contain the
3139
partial version number (example: "--version="1.7" would process 1.7.0,
3240
1.7.1, 1.7.2, etc.)
41+
new (bool): If True (default), only imports library versions for the most recent
42+
version, if False it processes all versions greater than or equal to min_release
43+
Overridden by --release if provided.
3344
"""
3445
click.secho("Saving library-version relationships...", fg="green")
3546

3647
min_release = f"boost-{min_release}"
37-
if release is None:
38-
versions = Version.objects.active().filter(name__gte=min_release)
48+
versions_qs = Version.objects.active().filter(name__gte=min_release)
49+
if release:
50+
versions = versions_qs.filter(name__icontains=release).order_by("-name")
51+
elif new:
52+
versions = [Version.objects.most_recent()]
3953
else:
40-
versions = Version.objects.filter(
41-
name__icontains=release, name__gte=min_release
42-
)
54+
versions = versions_qs.order_by("-name")
4355

44-
for version in versions.order_by("-name"):
56+
for version in versions:
4557
version_type = "branch" if version.slug in settings.BOOST_BRANCHES else "tag"
4658
click.secho(f"Saving libraries for version {version.name}", fg="green")
4759
import_library_versions.delay(

libraries/management/commands/release_tasks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def update_release_data(self) -> dict[str:int]:
100100
return self.handled_commits
101101

102102
def import_versions(self):
103-
call_command("import_versions", "--new")
103+
call_command("import_versions")
104104
self.latest_version = Version.objects.most_recent()
105105

106106
def import_library_versions(self):

versions/management/commands/import_archives_release_data.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,40 @@
1313
get_binary_checksums,
1414
get_binary_download_uris_for_release,
1515
)
16+
from structlog import get_logger
17+
18+
logger = get_logger(__name__)
1619

1720

1821
@click.command()
1922
@click.option("--release", is_flag=False, help="Release name")
20-
def command(release):
23+
@click.option(
24+
"--new",
25+
default=True,
26+
type=click.BOOL,
27+
help="Choose the newest version only from the db. false downloads all",
28+
)
29+
def command(release: str, new: bool):
2130
"""
2231
Import release data from the Boost artifactory.
2332
2433
This command will import the release data from the Boost artifactory for the
2534
specified release. If no release is specified, it will import the release data
26-
for all releases included in Artifactory.
35+
for the most recent release included in Artifactory. If --new is set to False,
36+
it will import the release data for all releases that are greater than or equal to
37+
the minimum release defined in settings.MIN_ARCHIVES_RELEASE.
2738
"""
2839
last_release = settings.MIN_ARCHIVES_RELEASE
2940

3041
if release:
3142
versions = Version.objects.filter(name__icontains=release)
43+
elif new:
44+
versions = [Version.objects.most_recent()]
3245
else:
3346
versions = Version.objects.filter(name__gte=last_release)
3447

3548
for v in versions:
49+
logger.info(f"Processing release {v.name}")
3650
version_num = v.name.replace("boost-", "")
3751
try:
3852
archives_urls = get_archives_download_uris_for_release(version_num)

versions/management/commands/import_artifactory_release_data.py

Lines changed: 0 additions & 50 deletions
This file was deleted.

versions/management/commands/import_release_notes.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44

55

66
@click.command()
7-
def command():
7+
@click.option("--new", default=True, help="Only import notes for new versions")
8+
def command(new: bool):
89
"""
910
Import and process release notes for all available versions.
1011
"""
1112

1213
click.secho("Importing release notes...", fg="green")
13-
import_release_notes.delay()
14+
import_release_notes.delay(new_versions_only=new)

versions/management/commands/import_versions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
@click.command()
77
@click.option("--delete-versions", is_flag=True, help="Delete all existing versions")
8-
@click.option("--new", is_flag=True, help="Only import new versions")
8+
@click.option("--new", default=True, help="Only import new versions")
99
@click.option("--token", is_flag=False, help="Github API token")
1010
def command(
1111
delete_versions,
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Generated by Django 4.2.16 on 2025-08-12 21:59
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
("versions", "0022_alter_reportconfiguration_version"),
10+
]
11+
12+
operations = [
13+
migrations.AddField(
14+
model_name="version",
15+
name="fully_imported",
16+
field=models.BooleanField(
17+
default=False,
18+
help_text="Whether this version has been fully imported and is ready for use.",
19+
),
20+
),
21+
]

0 commit comments

Comments
 (0)