Skip to content
This repository was archived by the owner on Jun 5, 2025. It is now read-only.

feat: import packages from external artifact #288

Merged
merged 1 commit into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/import_packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ jobs:
export BACKUP_FOLDER=backup
# Conditionally export the variables only if artifact download is enabled
if [ "${{ github.event.inputs.enable_artifact_download }}" == "true" ]; then
python scripts/import_packages.py
python scripts/import_packages.py --jsonl-dir /tmp/jsonl-files/
else
python scripts/import_packages.py --restore-backup False
python scripts/import_packages.py --restore-backup False --jsonl-dir /tmp/jsonl-files/
fi

- name: 'Upload Backup Files'
Expand Down
17 changes: 12 additions & 5 deletions scripts/import_packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@


class PackageImporter:
def __init__(self, take_backup=True, restore_backup=True):
def __init__(self, jsonl_dir='data', take_backup=True, restore_backup=True):
self.take_backup_flag = take_backup
self.restore_backup_flag = restore_backup

Expand All @@ -29,9 +29,9 @@ def __init__(self, take_backup=True, restore_backup=True):
)
)
self.json_files = [
"data/archived.jsonl",
"data/deprecated.jsonl",
"data/malicious.jsonl",
os.path.join(jsonl_dir, "archived.jsonl"),
os.path.join(jsonl_dir, "deprecated.jsonl"),
os.path.join(jsonl_dir, "malicious.jsonl"),
]
self.client.connect()
self.inference_engine = LlamaCppInferenceEngine()
Expand Down Expand Up @@ -149,9 +149,16 @@ async def run_import(self):
help="Specify whether to restore a backup before "
"data import (True or False). Default is True.",
)
parser.add_argument(
"--jsonl-dir",
type=str,
default="data",
help="Directory containing JSONL files. Default is 'data'."
)
args = parser.parse_args()

importer = PackageImporter(take_backup=args.take_backup, restore_backup=args.restore_backup)
importer = PackageImporter(jsonl_dir=args.jsonl_dir, take_backup=args.take_backup,
restore_backup=args.restore_backup)
asyncio.run(importer.run_import())
try:
assert importer.client.is_live()
Expand Down
Loading