Files
langflow/scripts/gp/upload_strings.py
RamGopalSrikar f0fd0040e8 fix: resolve ruff linting issues in GP scripts
- Fix quote style, import ordering, docstring format
- Use Path instead of os.makedirs/open/os.path.join
- Add missing timeouts to requests calls
- Move noqa comments to correct lines for S501
2026-03-18 10:23:55 -04:00

40 lines
1.1 KiB
Python

"""Upload English source strings to GP.
Usage:
python upload_strings.py --source path/to/en.json
"""
import argparse
import json
from pathlib import Path
from gp_client import GP_BUNDLE, create_bundle, list_bundles, upload_strings
def main():
parser = argparse.ArgumentParser(description="Upload strings to GP")
parser.add_argument("--source", required=True, help="Path to English source JSON file")
args = parser.parse_args()
# Load source strings
strings = json.loads(Path(args.source).read_text(encoding="utf-8"))
print(f"Loaded {len(strings)} strings from {args.source}")
# Create bundle if it doesn't exist
existing = list_bundles()
if GP_BUNDLE not in existing.get("bundleIds", []):
print(f"Creating bundle '{GP_BUNDLE}'...")
create_bundle()
print("Bundle created.")
else:
print(f"Bundle '{GP_BUNDLE}' already exists, skipping creation.")
# Upload English strings
print(f"Uploading strings to GP bundle '{GP_BUNDLE}'...")
result = upload_strings(strings)
print(f"Done: {result}")
if __name__ == "__main__":
main()