From 7e7c22f36133442383b0392ab92bec0c08a0a188 Mon Sep 17 00:00:00 2001 From: smellslikeml Date: Sun, 17 Dec 2023 20:50:17 -0800 Subject: [PATCH 1/5] reintroducing download --- ffmperative/bin/.gitignore | 4 ++++ ffmperative/bin/ffmp | 3 --- setup.py | 39 ++++++++++++++++++++++++++++++++++---- 3 files changed, 39 insertions(+), 7 deletions(-) create mode 100644 ffmperative/bin/.gitignore delete mode 100755 ffmperative/bin/ffmp diff --git a/ffmperative/bin/.gitignore b/ffmperative/bin/.gitignore new file mode 100644 index 0000000..5e7d273 --- /dev/null +++ b/ffmperative/bin/.gitignore @@ -0,0 +1,4 @@ +# Ignore everything in this directory +* +# Except this file +!.gitignore diff --git a/ffmperative/bin/ffmp b/ffmperative/bin/ffmp deleted file mode 100755 index eb4e95e..0000000 --- a/ffmperative/bin/ffmp +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:f73559384e1a596ce25ab21de650c74e9ef7cef4f73e141e53ccc5ace177eefe -size 1612975750 diff --git a/setup.py b/setup.py index acff162..7714a17 100644 --- a/setup.py +++ b/setup.py @@ -1,28 +1,59 @@ +import os +import requests from setuptools import setup, find_packages +from setuptools.command.install import install # read the contents of your README file from pathlib import Path this_directory = Path(__file__).parent long_description = (this_directory / "README.md").read_text() +version = "0.0.7" + def read_requirements(file): with open(file) as f: return [line.strip() for line in f if line.strip() and not line.startswith('#')] +class CustomInstall(install): + def run(self): + # Ensuring the bin/ directory exists + bin_dir = os.path.join(self.install_lib, 'ffmperative', 'bin') + os.makedirs(bin_dir, exist_ok=True) + + # Download the model + self.download_model(bin_dir) + + # Call the standard install command + install.run(self) + + @staticmethod + def download_model(bin_dir): + model_url = f"https://remyx.ai/assets/ffmperative/{version}/ffmp" + target_path = os.path.join(bin_dir, 'ffmp') + + if not os.path.exists(target_path): + print("Downloading model assets...") + response = requests.get(model_url, stream=True) + with open(target_path, 'wb') as f: + for chunk in response.iter_content(chunk_size=8192): + f.write(chunk) + print("Download complete.") + return target_path + setup( name="ffmperative", - version="0.0.7", + version=version, packages=find_packages(), include_package_data=True, - package_data={ - 'ffmperative': ['bin/ffmp'], - }, install_requires=read_requirements((this_directory / 'requirements.txt')), entry_points={ "console_scripts": [ "ffmperative=ffmperative.cli:main", ], }, + cmdclass={ + 'install': CustomInstall, + }, long_description=long_description, long_description_content_type='text/markdown' ) From 4cfea45ff5d16733385c4cb5e83f9ae3ddfa5b4b Mon Sep 17 00:00:00 2001 From: smellslikeml Date: Sun, 17 Dec 2023 21:45:12 -0800 Subject: [PATCH 2/5] add lazy download --- ffmperative/__init__.py | 2 ++ ffmperative/utils.py | 11 +++++++++++ setup.py | 17 ----------------- 3 files changed, 13 insertions(+), 17 deletions(-) diff --git a/ffmperative/__init__.py b/ffmperative/__init__.py index 588080c..56d2995 100644 --- a/ffmperative/__init__.py +++ b/ffmperative/__init__.py @@ -9,12 +9,14 @@ from . import tools as t from .prompts import MAIN_PROMPT +from .utils import download_ffmp from .tool_mapping import generate_tools_mapping from .interpretor import evaluate, extract_function_calls tools = generate_tools_mapping() def run_local(prompt): + download_ffmp() ffmp_path = pkg_resources.resource_filename('ffmperative', 'bin/ffmp') safe_prompt = shlex.quote(prompt) command = '{} -p "{}"'.format(ffmp_path, safe_prompt) diff --git a/ffmperative/utils.py b/ffmperative/utils.py index 9a388af..a2d8141 100644 --- a/ffmperative/utils.py +++ b/ffmperative/utils.py @@ -7,6 +7,17 @@ from pathlib import Path +def download_ffmp(): + ffmp_path = os.path.join(os.path.dirname(__file__), 'bin', 'ffmp') + if not os.path.exists(ffmp_path): + print("Downloading ffmp...") + model_url = "https://remyx.ai/assets/ffmperative/v0.0.7/ffmp" + response = requests.get(model_url, stream=True) + with open(ffmp_path, 'wb') as f: + for chunk in response.iter_content(chunk_size=8192): + f.write(chunk) + print("Download complete.") + def extract_and_encode_frame(video_path): # Get the duration of the video probe = ffmpeg.probe(video_path) diff --git a/setup.py b/setup.py index 7714a17..8da09ea 100644 --- a/setup.py +++ b/setup.py @@ -1,5 +1,4 @@ import os -import requests from setuptools import setup, find_packages from setuptools.command.install import install @@ -20,25 +19,9 @@ def run(self): bin_dir = os.path.join(self.install_lib, 'ffmperative', 'bin') os.makedirs(bin_dir, exist_ok=True) - # Download the model - self.download_model(bin_dir) - # Call the standard install command install.run(self) - @staticmethod - def download_model(bin_dir): - model_url = f"https://remyx.ai/assets/ffmperative/{version}/ffmp" - target_path = os.path.join(bin_dir, 'ffmp') - - if not os.path.exists(target_path): - print("Downloading model assets...") - response = requests.get(model_url, stream=True) - with open(target_path, 'wb') as f: - for chunk in response.iter_content(chunk_size=8192): - f.write(chunk) - print("Download complete.") - return target_path setup( name="ffmperative", From ca2d803a6813b1cff4e275bf7264715fa41c9caa Mon Sep 17 00:00:00 2001 From: smellslikeml Date: Sun, 17 Dec 2023 21:49:54 -0800 Subject: [PATCH 3/5] update download func --- ffmperative/utils.py | 9 ++++++++- setup.py | 16 +--------------- 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/ffmperative/utils.py b/ffmperative/utils.py index a2d8141..ea76205 100644 --- a/ffmperative/utils.py +++ b/ffmperative/utils.py @@ -8,7 +8,14 @@ from pathlib import Path def download_ffmp(): - ffmp_path = os.path.join(os.path.dirname(__file__), 'bin', 'ffmp') + bin_dir = os.path.join(os.path.dirname(__file__), 'bin') + ffmp_path = os.path.join(bin_dir, 'ffmp') + + # Create the 'bin/' directory if it does not exist + if not os.path.exists(bin_dir): + os.makedirs(bin_dir, exist_ok=True) + + # Download ffmp file if it does not exist if not os.path.exists(ffmp_path): print("Downloading ffmp...") model_url = "https://remyx.ai/assets/ffmperative/v0.0.7/ffmp" diff --git a/setup.py b/setup.py index 8da09ea..361aecc 100644 --- a/setup.py +++ b/setup.py @@ -7,25 +7,14 @@ this_directory = Path(__file__).parent long_description = (this_directory / "README.md").read_text() -version = "0.0.7" def read_requirements(file): with open(file) as f: return [line.strip() for line in f if line.strip() and not line.startswith('#')] -class CustomInstall(install): - def run(self): - # Ensuring the bin/ directory exists - bin_dir = os.path.join(self.install_lib, 'ffmperative', 'bin') - os.makedirs(bin_dir, exist_ok=True) - - # Call the standard install command - install.run(self) - - setup( name="ffmperative", - version=version, + version="0.0.7", packages=find_packages(), include_package_data=True, install_requires=read_requirements((this_directory / 'requirements.txt')), @@ -34,9 +23,6 @@ def run(self): "ffmperative=ffmperative.cli:main", ], }, - cmdclass={ - 'install': CustomInstall, - }, long_description=long_description, long_description_content_type='text/markdown' ) From b8b7e04412757dd15aa48832c9671db0f54ef27d Mon Sep 17 00:00:00 2001 From: smellslikeml Date: Sun, 17 Dec 2023 21:56:58 -0800 Subject: [PATCH 4/5] fix url --- ffmperative/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ffmperative/utils.py b/ffmperative/utils.py index ea76205..abdccbf 100644 --- a/ffmperative/utils.py +++ b/ffmperative/utils.py @@ -18,7 +18,7 @@ def download_ffmp(): # Download ffmp file if it does not exist if not os.path.exists(ffmp_path): print("Downloading ffmp...") - model_url = "https://remyx.ai/assets/ffmperative/v0.0.7/ffmp" + model_url = "https://remyx.ai/assets/ffmperative/0.0.7/ffmp" response = requests.get(model_url, stream=True) with open(ffmp_path, 'wb') as f: for chunk in response.iter_content(chunk_size=8192): From 1669618444deca8412c8d8f1a1b34446d5529581 Mon Sep 17 00:00:00 2001 From: smellslikeml Date: Sun, 17 Dec 2023 22:11:21 -0800 Subject: [PATCH 5/5] removed old lfs reference --- .gitattributes | 1 - 1 file changed, 1 deletion(-) delete mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index c0c6c95..0000000 --- a/.gitattributes +++ /dev/null @@ -1 +0,0 @@ -ffmperative/bin/ffmp filter=lfs diff=lfs merge=lfs -text