This is an automated email from the ASF dual-hosted git repository.
potiuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow-site-archive.git
The following commit(s) were added to refs/heads/main by this push:
new ce28754f2a Add pyproject.toml and number of processes to choose (#10)
ce28754f2a is described below
commit ce28754f2a8809d90e63b08666bef840718245e1
Author: Jarek Potiuk <[email protected]>
AuthorDate: Thu May 8 15:40:41 2025 +0200
Add pyproject.toml and number of processes to choose (#10)
---
.github/workflows/github-to-s3.yml | 8 ++-
.github/workflows/s3-to-github.yml | 9 ++-
.python-version | 1 +
pyproject.toml | 10 +++
scripts/github_to_s3.py | 19 ++---
scripts/s3_to_github.py | 11 +--
scripts/transfer_utils.py | 5 +-
uv.lock | 140 +++++++++++++++++++++++++++++++++++++
8 files changed, 185 insertions(+), 18 deletions(-)
diff --git a/.github/workflows/github-to-s3.yml
b/.github/workflows/github-to-s3.yml
index 64df1e3704..243e352542 100644
--- a/.github/workflows/github-to-s3.yml
+++ b/.github/workflows/github-to-s3.yml
@@ -43,6 +43,11 @@ on: # yamllint disable-line rule:truthy
options:
- last_commit
- full_sync
+ processes:
+ description: "Number of processes to use for syncing"
+ required: false
+ default: "8"
+ type: string
jobs:
github-to-s3:
name: GitHub to S3
@@ -89,5 +94,6 @@ jobs:
ls -la
python3 -m pip install uv
uv run ./scripts/github_to_s3.py --bucket-path
${{inputs.destination-location}} --local-path ${{inputs.local-path}} \
- --document-folder ${{inputs.document-folder}} --commit-sha
${COMMIT_SHA} --sync-type ${{ inputs.sync-type }}
+ --document-folder ${{inputs.document-folder}} --commit-sha
${COMMIT_SHA} --sync-type ${{ inputs.sync-type }} \
+ --processes ${{ inputs.processes }}
working-directory: /mnt/airflow-site-archive
diff --git a/.github/workflows/s3-to-github.yml
b/.github/workflows/s3-to-github.yml
index 0c0e0d56d2..9b61c6fc19 100644
--- a/.github/workflows/s3-to-github.yml
+++ b/.github/workflows/s3-to-github.yml
@@ -35,6 +35,11 @@ on: # yamllint disable-line rule:truthy
required: false
default: "NO_DOCS"
type: string
+ processes:
+ description: "Number of processes to use for syncing"
+ required: false
+ default: "8"
+ type: string
jobs:
s3-to-github:
name: S3 to GitHub
@@ -78,7 +83,9 @@ jobs:
- name: Syncing
run: |
python3 -m pip install uv
- uv run ./scripts/s3_to_github.py --bucket-path
${{inputs.source-location}} --local-path ${{inputs.local-destination}}
--document-folder ${{inputs.document-folder}}
+ uv run ./scripts/s3_to_github.py --bucket-path
${{inputs.source-location}} \
+ --local-path ${{inputs.local-destination}} --document-folder
${{inputs.document-folder}} \
+ --processes ${{inputs.processes}}
working-directory: /mnt/cloned-airflow-site-archive
- name: Commiting changes
diff --git a/.python-version b/.python-version
new file mode 100644
index 0000000000..e4fba21835
--- /dev/null
+++ b/.python-version
@@ -0,0 +1 @@
+3.12
diff --git a/pyproject.toml b/pyproject.toml
new file mode 100644
index 0000000000..a074dd5dc5
--- /dev/null
+++ b/pyproject.toml
@@ -0,0 +1,10 @@
+[project]
+name = "airflow-site-archive"
+version = "0.1.0"
+description = "Airflow site archive for old/versioned docs"
+readme = "README.md"
+requires-python = ">=3.12"
+dependencies = [
+ "boto3>=1.38.11",
+ "rich>=14.0.0",
+]
diff --git a/scripts/github_to_s3.py b/scripts/github_to_s3.py
index c146064961..3f00f4d8cc 100644
--- a/scripts/github_to_s3.py
+++ b/scripts/github_to_s3.py
@@ -18,8 +18,8 @@
# /// script
# requires-python = ">=3.11"
# dependencies = [
-# "rich",
-# "boto3",
+# "boto3>=1.38.11",
+# "rich>=14.0.0",
# ]
# ///
@@ -61,7 +61,7 @@ class GithubToS3(CommonTransferUtils):
return []
return result.stdout.splitlines() if result.stdout else []
- def sync_last_commit_files(self, commit_sha: str):
+ def sync_last_commit_files(self, commit_sha: str, processes: int):
'''
There are two parts here.
1. When any file gets removed under docs folder, we will remove from
target location
@@ -88,10 +88,10 @@ class GithubToS3(CommonTransferUtils):
dest = f"s3://{self.bucket_name}/{destination_prefix}"
delete_files_pool_args.append(dest)
- self.run_with_pool(self.remove, delete_files_pool_args)
- self.run_with_pool(self.copy, copy_files_pool_args)
+ self.run_with_pool(self.remove, delete_files_pool_args,
processes=processes)
+ self.run_with_pool(self.copy, copy_files_pool_args,
processes=processes)
- def full_sync(self):
+ def full_sync(self, processes: int):
console.print(f"[blue] Syncing all files from {self.local_path} to
{self.bucket_name} [/]")
list_of_folders = os.listdir(self.local_path)
pool_args = []
@@ -100,7 +100,7 @@ class GithubToS3(CommonTransferUtils):
dest = f"s3://{self.bucket_name}/{self.prefix}".rstrip("/") + "/"
+ folder
pool_args.append((source, dest))
- self.run_with_pool(self.sync, pool_args)
+ self.run_with_pool(self.sync, pool_args, processes=processes)
@@ -111,6 +111,7 @@ if __name__ == "__main__":
parser.add_argument("--document-folder", help="Document folder to sync",
default="")
parser.add_argument("--commit-sha", help="Commit SHA to sync", default="")
parser.add_argument("--sync-type", help="Sync type", default="last_commit")
+ parser.add_argument("--processes", help="Number of processes", type=int,
default=8)
args = parser.parse_args()
@@ -133,11 +134,11 @@ if __name__ == "__main__":
if args.sync_type == "last_commit" and args.commit_sha:
console.print(f"[blue] Syncing last commit {args.commit_sha} from
{args.local_path} [/]")
- syncer.sync_last_commit_files(args.commit_sha)
+ syncer.sync_last_commit_files(args.commit_sha,
processes=int(args.processes))
sys.exit(0)
if args.sync_type == "full_sync":
- syncer.full_sync()
+ syncer.full_sync(processes=int(args.processes))
sys.exit(0)
console.print(f"[red] Invalid sync type {args.sync_type} [/]")
diff --git a/scripts/s3_to_github.py b/scripts/s3_to_github.py
index ff126af50f..47636d2b5d 100644
--- a/scripts/s3_to_github.py
+++ b/scripts/s3_to_github.py
@@ -18,8 +18,8 @@
# /// script
# requires-python = ">=3.11"
# dependencies = [
-# "rich",
-# "boto3",
+# "boto3>=1.38.11",
+# "rich>=14.0.0",
# ]
# ///
@@ -45,7 +45,7 @@ class S3TOGithub(CommonTransferUtils):
)
return response["KeyCount"] > 0
- def sync_to_s3(self):
+ def sync_to_s3(self, processes: int):
console.print("[blue] Syncing files from S3 to GitHub...[/]")
prefixes = self.get_list_of_folders()
pool_args = []
@@ -56,7 +56,7 @@ class S3TOGithub(CommonTransferUtils):
destination = self.local_path + pref.replace("docs/", "")
pool_args.append((source_bucket_path, destination))
- self.run_with_pool(self.sync, pool_args)
+ self.run_with_pool(self.sync, pool_args, processes=processes)
@@ -65,6 +65,7 @@ if __name__ == "__main__":
parser.add_argument("--bucket-path", required=True, help="S3 bucket name
with path")
parser.add_argument("--local-path", required=True, help="local path to
sync")
parser.add_argument("--document-folder", help="Document folder to sync",
default="")
+ parser.add_argument("--processes", help="Number of processes", type=int,
default=8)
args = parser.parse_args()
@@ -84,7 +85,7 @@ if __name__ == "__main__":
console.print(f"[red] Document folder {document_folder} does not
exist in bucket {args.bucket_path}.[/]")
sys.exit(1)
- syncer.sync_to_s3()
+ syncer.sync_to_s3(processes=int(args.processes))
diff --git a/scripts/transfer_utils.py b/scripts/transfer_utils.py
index b0748ea9d4..132ff00bd2 100644
--- a/scripts/transfer_utils.py
+++ b/scripts/transfer_utils.py
@@ -3,6 +3,7 @@ import sys
from functools import cached_property
from multiprocessing import Pool
from pathlib import Path
+from typing import Callable, Any
import boto3
import urllib3
@@ -83,9 +84,9 @@ class CommonTransferUtils:
console.print(f"[blue] Sync completed for {source} to {destination}
[/]")
@staticmethod
- def run_with_pool(func, args):
+ def run_with_pool(func: Callable, args: Any, processes: int = 4):
- with Pool(processes=4) as pool:
+ with Pool(processes=processes) as pool:
if all(isinstance(arg, tuple) for arg in args):
pool.starmap(func, args)
else:
diff --git a/uv.lock b/uv.lock
new file mode 100644
index 0000000000..0212126003
--- /dev/null
+++ b/uv.lock
@@ -0,0 +1,140 @@
+version = 1
+revision = 2
+requires-python = ">=3.12"
+
+[[package]]
+name = "airflow-site-archive"
+version = "0.1.0"
+source = { virtual = "." }
+dependencies = [
+ { name = "boto3" },
+ { name = "rich" },
+]
+
+[package.metadata]
+requires-dist = [
+ { name = "boto3", specifier = ">=1.38.11" },
+ { name = "rich", specifier = ">=14.0.0" },
+]
+
+[[package]]
+name = "boto3"
+version = "1.38.11"
+source = { registry = "https://pypi.org/simple" }
+dependencies = [
+ { name = "botocore" },
+ { name = "jmespath" },
+ { name = "s3transfer" },
+]
+sdist = { url =
"https://files.pythonhosted.org/packages/ec/43/8dbf7397a7d3a66a2e65caa3818001437145a137802799c38691f446e732/boto3-1.38.11.tar.gz",
hash =
"sha256:ecf141395b8ede64dbc975c62a55fbb2231fc3e50904d65c088bc83ae98595cf", size
= 111765, upload_time = "2025-05-07T19:34:30.124Z" }
+wheels = [
+ { url =
"https://files.pythonhosted.org/packages/9a/ea/89465bab299d9813412fdeb6fb09b215d3a842b6f352b3741f68269f9935/boto3-1.38.11-py3-none-any.whl",
hash =
"sha256:dc3ff3a382d33d1e7e4141a5c63d084faf90657d6008ef917a3e64cfcbbb47e0", size
= 139915, upload_time = "2025-05-07T19:34:27.723Z" },
+]
+
+[[package]]
+name = "botocore"
+version = "1.38.11"
+source = { registry = "https://pypi.org/simple" }
+dependencies = [
+ { name = "jmespath" },
+ { name = "python-dateutil" },
+ { name = "urllib3" },
+]
+sdist = { url =
"https://files.pythonhosted.org/packages/22/5d/96ec53163bb60f16777af91f5412df73beb79675d264fd3f1cd57dcea2fe/botocore-1.38.11.tar.gz",
hash =
"sha256:44c5cb042fefedbe0b0ae4c3f96aed03f4cab6973d4317410c8d7c6d32807aef", size
= 13884039, upload_time = "2025-05-07T19:34:17.621Z" }
+wheels = [
+ { url =
"https://files.pythonhosted.org/packages/07/06/bbad7f3e96798b30a7d6a9b0be4be4cbf3793d476ff6578b7f1322221c37/botocore-1.38.11-py3-none-any.whl",
hash =
"sha256:f5cb7a292774d4a212347475d95668bb96c1fe322e71c19bf871fb06503597a5", size
= 13541099, upload_time = "2025-05-07T19:34:12.618Z" },
+]
+
+[[package]]
+name = "jmespath"
+version = "1.0.1"
+source = { registry = "https://pypi.org/simple" }
+sdist = { url =
"https://files.pythonhosted.org/packages/00/2a/e867e8531cf3e36b41201936b7fa7ba7b5702dbef42922193f05c8976cd6/jmespath-1.0.1.tar.gz",
hash =
"sha256:90261b206d6defd58fdd5e85f478bf633a2901798906be2ad389150c5c60edbe", size
= 25843, upload_time = "2022-06-17T18:00:12.224Z" }
+wheels = [
+ { url =
"https://files.pythonhosted.org/packages/31/b4/b9b800c45527aadd64d5b442f9b932b00648617eb5d63d2c7a6587b7cafc/jmespath-1.0.1-py3-none-any.whl",
hash =
"sha256:02e2e4cc71b5bcab88332eebf907519190dd9e6e82107fa7f83b1003a6252980", size
= 20256, upload_time = "2022-06-17T18:00:10.251Z" },
+]
+
+[[package]]
+name = "markdown-it-py"
+version = "3.0.0"
+source = { registry = "https://pypi.org/simple" }
+dependencies = [
+ { name = "mdurl" },
+]
+sdist = { url =
"https://files.pythonhosted.org/packages/38/71/3b932df36c1a044d397a1f92d1cf91ee0a503d91e470cbd670aa66b07ed0/markdown-it-py-3.0.0.tar.gz",
hash =
"sha256:e3f60a94fa066dc52ec76661e37c851cb232d92f9886b15cb560aaada2df8feb", size
= 74596, upload_time = "2023-06-03T06:41:14.443Z" }
+wheels = [
+ { url =
"https://files.pythonhosted.org/packages/42/d7/1ec15b46af6af88f19b8e5ffea08fa375d433c998b8a7639e76935c14f1f/markdown_it_py-3.0.0-py3-none-any.whl",
hash =
"sha256:355216845c60bd96232cd8d8c40e8f9765cc86f46880e43a8fd22dc1a1a8cab1", size
= 87528, upload_time = "2023-06-03T06:41:11.019Z" },
+]
+
+[[package]]
+name = "mdurl"
+version = "0.1.2"
+source = { registry = "https://pypi.org/simple" }
+sdist = { url =
"https://files.pythonhosted.org/packages/d6/54/cfe61301667036ec958cb99bd3efefba235e65cdeb9c84d24a8293ba1d90/mdurl-0.1.2.tar.gz",
hash =
"sha256:bb413d29f5eea38f31dd4754dd7377d4465116fb207585f97bf925588687c1ba", size
= 8729, upload_time = "2022-08-14T12:40:10.846Z" }
+wheels = [
+ { url =
"https://files.pythonhosted.org/packages/b3/38/89ba8ad64ae25be8de66a6d463314cf1eb366222074cfda9ee839c56a4b4/mdurl-0.1.2-py3-none-any.whl",
hash =
"sha256:84008a41e51615a49fc9966191ff91509e3c40b939176e643fd50a5c2196b8f8", size
= 9979, upload_time = "2022-08-14T12:40:09.779Z" },
+]
+
+[[package]]
+name = "pygments"
+version = "2.19.1"
+source = { registry = "https://pypi.org/simple" }
+sdist = { url =
"https://files.pythonhosted.org/packages/7c/2d/c3338d48ea6cc0feb8446d8e6937e1408088a72a39937982cc6111d17f84/pygments-2.19.1.tar.gz",
hash =
"sha256:61c16d2a8576dc0649d9f39e089b5f02bcd27fba10d8fb4dcc28173f7a45151f", size
= 4968581, upload_time = "2025-01-06T17:26:30.443Z" }
+wheels = [
+ { url =
"https://files.pythonhosted.org/packages/8a/0b/9fcc47d19c48b59121088dd6da2488a49d5f72dacf8262e2790a1d2c7d15/pygments-2.19.1-py3-none-any.whl",
hash =
"sha256:9ea1544ad55cecf4b8242fab6dd35a93bbce657034b0611ee383099054ab6d8c", size
= 1225293, upload_time = "2025-01-06T17:26:25.553Z" },
+]
+
+[[package]]
+name = "python-dateutil"
+version = "2.9.0.post0"
+source = { registry = "https://pypi.org/simple" }
+dependencies = [
+ { name = "six" },
+]
+sdist = { url =
"https://files.pythonhosted.org/packages/66/c0/0c8b6ad9f17a802ee498c46e004a0eb49bc148f2fd230864601a86dcf6db/python-dateutil-2.9.0.post0.tar.gz",
hash =
"sha256:37dd54208da7e1cd875388217d5e00ebd4179249f90fb72437e91a35459a0ad3", size
= 342432, upload_time = "2024-03-01T18:36:20.211Z" }
+wheels = [
+ { url =
"https://files.pythonhosted.org/packages/ec/57/56b9bcc3c9c6a792fcbaf139543cee77261f3651ca9da0c93f5c1221264b/python_dateutil-2.9.0.post0-py2.py3-none-any.whl",
hash =
"sha256:a8b2bc7bffae282281c8140a97d3aa9c14da0b136dfe83f850eea9a5f7470427", size
= 229892, upload_time = "2024-03-01T18:36:18.57Z" },
+]
+
+[[package]]
+name = "rich"
+version = "14.0.0"
+source = { registry = "https://pypi.org/simple" }
+dependencies = [
+ { name = "markdown-it-py" },
+ { name = "pygments" },
+]
+sdist = { url =
"https://files.pythonhosted.org/packages/a1/53/830aa4c3066a8ab0ae9a9955976fb770fe9c6102117c8ec4ab3ea62d89e8/rich-14.0.0.tar.gz",
hash =
"sha256:82f1bc23a6a21ebca4ae0c45af9bdbc492ed20231dcb63f297d6d1021a9d5725", size
= 224078, upload_time = "2025-03-30T14:15:14.23Z" }
+wheels = [
+ { url =
"https://files.pythonhosted.org/packages/0d/9b/63f4c7ebc259242c89b3acafdb37b41d1185c07ff0011164674e9076b491/rich-14.0.0-py3-none-any.whl",
hash =
"sha256:1c9491e1951aac09caffd42f448ee3d04e58923ffe14993f6e83068dc395d7e0", size
= 243229, upload_time = "2025-03-30T14:15:12.283Z" },
+]
+
+[[package]]
+name = "s3transfer"
+version = "0.12.0"
+source = { registry = "https://pypi.org/simple" }
+dependencies = [
+ { name = "botocore" },
+]
+sdist = { url =
"https://files.pythonhosted.org/packages/fc/9e/73b14aed38ee1f62cd30ab93cd0072dec7fb01f3033d116875ae3e7b8b44/s3transfer-0.12.0.tar.gz",
hash =
"sha256:8ac58bc1989a3fdb7c7f3ee0918a66b160d038a147c7b5db1500930a607e9a1c", size
= 149178, upload_time = "2025-04-22T21:08:09.787Z" }
+wheels = [
+ { url =
"https://files.pythonhosted.org/packages/89/64/d2b49620039b82688aeebd510bd62ff4cdcdb86cbf650cc72ae42c5254a3/s3transfer-0.12.0-py3-none-any.whl",
hash =
"sha256:35b314d7d82865756edab59f7baebc6b477189e6ab4c53050e28c1de4d9cce18", size
= 84773, upload_time = "2025-04-22T21:08:08.265Z" },
+]
+
+[[package]]
+name = "six"
+version = "1.17.0"
+source = { registry = "https://pypi.org/simple" }
+sdist = { url =
"https://files.pythonhosted.org/packages/94/e7/b2c673351809dca68a0e064b6af791aa332cf192da575fd474ed7d6f16a2/six-1.17.0.tar.gz",
hash =
"sha256:ff70335d468e7eb6ec65b95b99d3a2836546063f63acc5171de367e834932a81", size
= 34031, upload_time = "2024-12-04T17:35:28.174Z" }
+wheels = [
+ { url =
"https://files.pythonhosted.org/packages/b7/ce/149a00dd41f10bc29e5921b496af8b574d8413afcd5e30dfa0ed46c2cc5e/six-1.17.0-py2.py3-none-any.whl",
hash =
"sha256:4721f391ed90541fddacab5acf947aa0d3dc7d27b2e1e8eda2be8970586c3274", size
= 11050, upload_time = "2024-12-04T17:35:26.475Z" },
+]
+
+[[package]]
+name = "urllib3"
+version = "2.4.0"
+source = { registry = "https://pypi.org/simple" }
+sdist = { url =
"https://files.pythonhosted.org/packages/8a/78/16493d9c386d8e60e442a35feac5e00f0913c0f4b7c217c11e8ec2ff53e0/urllib3-2.4.0.tar.gz",
hash =
"sha256:414bc6535b787febd7567804cc015fee39daab8ad86268f1310a9250697de466", size
= 390672, upload_time = "2025-04-10T15:23:39.232Z" }
+wheels = [
+ { url =
"https://files.pythonhosted.org/packages/6b/11/cc635220681e93a0183390e26485430ca2c7b5f9d33b15c74c2861cb8091/urllib3-2.4.0-py3-none-any.whl",
hash =
"sha256:4e16665048960a0900c702d4a66415956a584919c03361cac9f1df5c5dd7e813", size
= 128680, upload_time = "2025-04-10T15:23:37.377Z" },
+]