From f23c7ced2c6448c22acd1400ed453490fb156a04 Mon Sep 17 00:00:00 2001 From: Eitan Turok <150733043+eitanturok@users.noreply.github.com> Date: Wed, 31 Jul 2024 11:53:53 -0400 Subject: [PATCH 1/7] read version from _version.py file --- llmfoundry/__init__.py | 5 ++--- llmfoundry/_version.py | 6 ++++++ setup.py | 17 ++++++++--------- 3 files changed, 16 insertions(+), 12 deletions(-) create mode 100644 llmfoundry/_version.py diff --git a/llmfoundry/__init__.py b/llmfoundry/__init__.py index 8dbd180c0a..8815573c4c 100644 --- a/llmfoundry/__init__.py +++ b/llmfoundry/__init__.py @@ -26,6 +26,7 @@ ' in LLM Foundry setup.py and update accordingly. The latest Docker image can be found in the README.', ) from e +from llmfoundry._version import __version__ from llmfoundry.utils.logging_utils import SpecificWarningFilter # Filter out Hugging Face warning for not using a pinned revision of the model @@ -86,6 +87,4 @@ 'optim', 'tokenizers', 'utils', -] - -__version__ = '0.11.0.dev0' +] \ No newline at end of file diff --git a/llmfoundry/_version.py b/llmfoundry/_version.py new file mode 100644 index 0000000000..a8256924a3 --- /dev/null +++ b/llmfoundry/_version.py @@ -0,0 +1,6 @@ +# Copyright 2024 MosaicML LLM Foundry authors +# SPDX-License-Identifier: Apache-2.0 + +"""The LLM Foundry Version.""" + +__version__ = '0.10.0' \ No newline at end of file diff --git a/setup.py b/setup.py index bc84f9fac8..3417777a06 100644 --- a/setup.py +++ b/setup.py @@ -6,6 +6,7 @@ import copy import os import re +from typing import Any, Dict, Mapping import setuptools from setuptools import setup @@ -15,17 +16,15 @@ _REPO_REAL_PATH = os.path.dirname(os.path.realpath(__file__)) _PACKAGE_REAL_PATH = os.path.join(_REPO_REAL_PATH, _PACKAGE_DIR) -# Read the repo version +# Read the composer version # We can't use `.__version__` from the library since it's not installed yet -with open(os.path.join(_PACKAGE_REAL_PATH, '__init__.py')) as f: +version_path = os.path.join(_PACKAGE_REAL_PATH, '_version.py') +with open(version_path, encoding='utf-8') as f: + version_globals: Dict[str, Any] = {} + version_locals: Mapping[str, object] = {} content = f.read() -# regex: '__version__', whitespace?, '=', whitespace, quote, version, quote -# we put parens around the version so that it becomes elem 1 of the match -expr = re.compile( - r"""^__version__\s*=\s*['"]([0-9]+\.[0-9]+\.[0-9]+(?:\.\w+)?)['"]""", - re.MULTILINE, -) -repo_version = expr.findall(content)[0] + exec(content, version_globals, version_locals) + repo_version = version_locals['__version__'] # Use repo README for PyPi description with open('README.md', 'r', encoding='utf-8') as fh: From 961e3a9868d852bbccc4c38c21e475cc4b1346d6 Mon Sep 17 00:00:00 2001 From: Eitan Turok Date: Wed, 31 Jul 2024 16:06:52 +0000 Subject: [PATCH 2/7] format + lint --- llmfoundry/__init__.py | 3 +-- llmfoundry/_version.py | 2 +- setup.py | 1 - 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/llmfoundry/__init__.py b/llmfoundry/__init__.py index 8815573c4c..343c5a3b51 100644 --- a/llmfoundry/__init__.py +++ b/llmfoundry/__init__.py @@ -26,7 +26,6 @@ ' in LLM Foundry setup.py and update accordingly. The latest Docker image can be found in the README.', ) from e -from llmfoundry._version import __version__ from llmfoundry.utils.logging_utils import SpecificWarningFilter # Filter out Hugging Face warning for not using a pinned revision of the model @@ -87,4 +86,4 @@ 'optim', 'tokenizers', 'utils', -] \ No newline at end of file +] diff --git a/llmfoundry/_version.py b/llmfoundry/_version.py index a8256924a3..ce40be19de 100644 --- a/llmfoundry/_version.py +++ b/llmfoundry/_version.py @@ -3,4 +3,4 @@ """The LLM Foundry Version.""" -__version__ = '0.10.0' \ No newline at end of file +__version__ = '0.10.0' diff --git a/setup.py b/setup.py index 3417777a06..533b205c32 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,6 @@ import copy import os -import re from typing import Any, Dict, Mapping import setuptools From 6f305f3d4f0bf285c64fd98eda414dcfd129118c Mon Sep 17 00:00:00 2001 From: Eitan Turok Date: Wed, 31 Jul 2024 16:23:36 +0000 Subject: [PATCH 3/7] fix typo + type check --- setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 533b205c32..185d3970f7 100644 --- a/setup.py +++ b/setup.py @@ -15,7 +15,7 @@ _REPO_REAL_PATH = os.path.dirname(os.path.realpath(__file__)) _PACKAGE_REAL_PATH = os.path.join(_REPO_REAL_PATH, _PACKAGE_DIR) -# Read the composer version +# Read the llm-foundry version # We can't use `.__version__` from the library since it's not installed yet version_path = os.path.join(_PACKAGE_REAL_PATH, '_version.py') with open(version_path, encoding='utf-8') as f: @@ -23,7 +23,7 @@ version_locals: Mapping[str, object] = {} content = f.read() exec(content, version_globals, version_locals) - repo_version = version_locals['__version__'] + repo_version = str(version_locals['__version__']) # Use repo README for PyPi description with open('README.md', 'r', encoding='utf-8') as fh: From 9a01a8f06c37b550254325b0881ab007a6e6edbf Mon Sep 17 00:00:00 2001 From: Eitan Turok Date: Wed, 31 Jul 2024 16:27:22 +0000 Subject: [PATCH 4/7] add imports --- llmfoundry/callbacks/async_eval_callback.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/llmfoundry/callbacks/async_eval_callback.py b/llmfoundry/callbacks/async_eval_callback.py index 646d86c8d3..1b3c31e861 100644 --- a/llmfoundry/callbacks/async_eval_callback.py +++ b/llmfoundry/callbacks/async_eval_callback.py @@ -557,7 +557,8 @@ def launch_run(self, checkpoint: str, current_interval: Time) -> Run: installation_path = i['path'] if not found_llm_foundry: - from llmfoundry import __version__ as latest_foundry_version + from llmfoundry._version import \ + __version__ as latest_foundry_version # If github integration is not found, foundry is likely installed # through the run command. In this case, we'll add the integration From 20c81005fd90c033d891d6c0de91a3ef092eb65d Mon Sep 17 00:00:00 2001 From: Eitan Turok <150733043+eitanturok@users.noreply.github.com> Date: Wed, 31 Jul 2024 12:51:44 -0400 Subject: [PATCH 5/7] Update llmfoundry/_version.py Co-authored-by: Mihir Patel --- llmfoundry/_version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/llmfoundry/_version.py b/llmfoundry/_version.py index ce40be19de..4c11746b43 100644 --- a/llmfoundry/_version.py +++ b/llmfoundry/_version.py @@ -3,4 +3,4 @@ """The LLM Foundry Version.""" -__version__ = '0.10.0' +__version__ = '0.11.0.dev' From ac1dd82562f30ad72058ea8f32534dedfaa816b3 Mon Sep 17 00:00:00 2001 From: Eitan Turok Date: Wed, 31 Jul 2024 18:27:29 +0000 Subject: [PATCH 6/7] add imports --- llmfoundry/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/llmfoundry/__init__.py b/llmfoundry/__init__.py index 343c5a3b51..6da0cb59c5 100644 --- a/llmfoundry/__init__.py +++ b/llmfoundry/__init__.py @@ -36,6 +36,7 @@ logger.addFilter(new_files_warning_filter) +from llmfoundry._version import __version__ from llmfoundry import ( algorithms, callbacks, From 0b84d4cc49876a5c6fd0e81b451cc02289a75433 Mon Sep 17 00:00:00 2001 From: Eitan Turok Date: Wed, 31 Jul 2024 18:48:09 +0000 Subject: [PATCH 7/7] include __version__ in all --- llmfoundry/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/llmfoundry/__init__.py b/llmfoundry/__init__.py index 6da0cb59c5..b851aaa559 100644 --- a/llmfoundry/__init__.py +++ b/llmfoundry/__init__.py @@ -36,7 +36,6 @@ logger.addFilter(new_files_warning_filter) -from llmfoundry._version import __version__ from llmfoundry import ( algorithms, callbacks, @@ -51,6 +50,7 @@ tokenizers, utils, ) +from llmfoundry._version import __version__ from llmfoundry.data import StreamingFinetuningDataset, StreamingTextDataset from llmfoundry.eval import InContextLearningDataset, InContextLearningMetric from llmfoundry.models.hf import ComposerHFCausalLM @@ -64,6 +64,7 @@ from llmfoundry.optim import DecoupledLionW __all__ = [ + '__version__', 'StreamingFinetuningDataset', 'StreamingTextDataset', 'InContextLearningDataset',