Created
July 31, 2023 18:22
-
-
Save greenido/31285c57cb7b4f462cd3f308a5d909d2 to your computer and use it in GitHub Desktop.
A script to push a new LLM (Large Language Model) model to JFrog Artifactory (under 30 lines of code :)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
# Artifactory configuration - Change it to your own settings | |
ARTIFACTORY_URL = 'https://your-artifactory-url.com' | |
ARTIFACTORY_REPO = 'your-repo-name' | |
ARTIFACTORY_USERNAME = 'your-username' | |
ARTIFACTORY_API_KEY = 'your-api-key' | |
# LLM model file path | |
LLM_MODEL_FILE = 'path/to/your/llm_model.tar.gz' | |
def push_to_artifactory(): | |
url = f'{ARTIFACTORY_URL}/{ARTIFACTORY_REPO}/llm_model.tar.gz' | |
headers = { | |
'Authorization': f'Bearer {ARTIFACTORY_API_KEY}', | |
'X-JFrog-Art-Api': ARTIFACTORY_API_KEY | |
} | |
with open(LLM_MODEL_FILE, 'rb') as file: | |
data = file.read() | |
try: | |
response = requests.put(url, headers=headers, data=data) | |
if response.status_code == 201: | |
print("LLM model pushed to Artifactory successfully!") | |
else: | |
print(f"Failed to push LLM model. Status Code: {response.status_code}, Message: {response.text}") | |
except requests.exceptions.RequestException as e: | |
print(f"Error while pushing the LLM model to Artifactory: {e}") | |
if __name__ == "__main__": | |
push_to_artifactory() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment