From 018b2557abd6a144383cfd01d00974850cec7512 Mon Sep 17 00:00:00 2001 From: Rajat Sen Date: Tue, 7 Oct 2025 21:38:22 +0000 Subject: [PATCH 1/7] changes to workflow --- .github/workflows/main.yml | 24 +++---- .github/workflows/manual_publish.yml | 25 +++++++ .gitignore | 1 + README.md | 27 ++++++-- pyproject.toml | 34 +++++----- requirements.txt | 99 ++++++++++++++++++++++++++++ 6 files changed, 171 insertions(+), 39 deletions(-) create mode 100644 .github/workflows/manual_publish.yml create mode 100644 requirements.txt diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 18654b7..6aa04b1 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,4 +1,4 @@ -name: Poetry publish +name: Python package build on: push: @@ -7,24 +7,20 @@ on: branches: [ "master" ] jobs: - buildPush: + build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - name: Set up Python uses: actions/setup-python@v2 with: - python-version: '3.10' - - name: Install Poetry + python-version: '3.11' + - name: Install uv run: | - python -m pip install --upgrade pip - pip install poetry - # use the hardcoded version number for now. if this is merged to the main repo, you can uncomment these lines to automatically tag the version number with the github run number - # e.g. poetry version 0.1.${{ github.run_number }} - - name: Set Version number + curl -LsSf https://astral.sh/uv/install.sh | sh + echo "$HOME/.cargo/bin" >> $GITHUB_PATH + - name: Install build dependencies run: | - poetry version 1.3.0 - - name: Build and Publish to PyPI - run: | - poetry config pypi-token.pypi ${{ secrets.PYPI_API_TOKEN }} - poetry publish --build + uv pip install build + - name: Build package + run: python -m build \ No newline at end of file diff --git a/.github/workflows/manual_publish.yml b/.github/workflows/manual_publish.yml new file mode 100644 index 0000000..473a742 --- /dev/null +++ b/.github/workflows/manual_publish.yml @@ -0,0 +1,25 @@ +name: Manual PyPI Publish + +on: + workflow_dispatch: + +jobs: + build-and-publish: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.11' + - name: Install uv + run: | + curl -LsSf https://astral.sh/uv/install.sh | sh + echo "$HOME/.cargo/bin" >> $GITHUB_PATH + - name: Install Poetry + run: | + uv pip install poetry + - name: Build and Publish to PyPI + run: | + poetry config pypi-token.pypi ${{ secrets.PYPI_API_TOKEN }} + poetry publish --build diff --git a/.gitignore b/.gitignore index c39ae71..589bbfc 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ wandb/ datasets/ results/ timesfm_jax.egg-info/ +development_setup.md diff --git a/README.md b/README.md index 546c5bd..3479b00 100644 --- a/README.md +++ b/README.md @@ -44,15 +44,28 @@ will be under construction over the next few weeks to ### Install -TODO(siriuz42): Package timesfm==2.0.0 and upload to PyPI . +1. Clone the repository: + ```shell + git clone https://github.com/google-research/timesfm.git + cd timesfm + ``` -Run +2. Create a virtual environment and install dependencies using `uv`: + ```shell + # Create a virtual environment + uv venv + + # Activate the environment + source .venv/bin/activate + + # Install the dependencies + uv pip install -r requirements.txt + ``` -```shell -git clone https://github.com/google-research/timesfm.git -cd timesfm -pip install -e . -``` +3. (Optional) If you plan to modify the source code, install the package in editable mode: + ```shell + uv pip install -e . + ``` ### Code Example diff --git a/pyproject.toml b/pyproject.toml index 734a5b9..ceb12f4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,31 +1,29 @@ -[tool.poetry] +[project] name = "timesfm" version = "2.0.0" description = "A time series foundation model." authors = [ - "Rajat Sen ", - "Yichen Zhou ", - "Abhimanyu Das ", - "Petros Mol ", - "Michael Chertushkin " + {name = "Rajat Sen", email = "senrajat@google.com"}, + {name = "Yichen Zhou", email = "yichenzhou@google.com"}, + {name = "Abhimanyu Das", email = "abhidas@google.com"}, + {name = "Petros Mol", email = "pmol@google.com"}, + {name = "Michael Chertushkin", email = "chertushkinmichael@gmail.com"}, ] -license = "Apache-2.0" +license = {text = "Apache-2.0"} readme = "README.md" -packages = [{include = "timesfm", from = "src"}] - -[tool.poetry.dependencies] -python = ">=3.11" -numpy = ">=1.26.4" -huggingface_hub = { version = ">=0.23.0", extras = ["cli"] } -safetensors = ">=0.5.3" -torch = { version = ">=2.0.0", extras = ["cuda"] } +requires-python = ">=3.11" +dependencies = [ + "numpy>=1.26.4", + "huggingface_hub[cli]>=0.23.0", + "safetensors>=0.5.3", + "torch>=2.0.0", +] [tool.ruff] line-length = 88 indent-width = 2 - [build-system] -requires = ["poetry-core"] -build-backend = "poetry.core.masonry.api" +requires = ["setuptools>=61.0"] +build-backend = "setuptools.build_meta" diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..2b93766 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,99 @@ +# This file was autogenerated by uv via the following command: +# uv pip compile pyproject.toml -o requirements.txt +certifi==2025.10.5 + # via requests +charset-normalizer==3.4.3 + # via requests +filelock==3.19.1 + # via + # huggingface-hub + # torch +fsspec==2025.9.0 + # via + # huggingface-hub + # torch +hf-xet==1.1.10 + # via huggingface-hub +huggingface-hub==0.35.3 + # via timesfm (pyproject.toml) +idna==3.10 + # via requests +inquirerpy==0.3.4 + # via huggingface-hub +jinja2==3.1.6 + # via torch +markupsafe==3.0.3 + # via jinja2 +mpmath==1.3.0 + # via sympy +networkx==3.5 + # via torch +numpy==2.3.3 + # via timesfm (pyproject.toml) +nvidia-cublas-cu12==12.8.4.1 + # via + # nvidia-cudnn-cu12 + # nvidia-cusolver-cu12 + # torch +nvidia-cuda-cupti-cu12==12.8.90 + # via torch +nvidia-cuda-nvrtc-cu12==12.8.93 + # via torch +nvidia-cuda-runtime-cu12==12.8.90 + # via torch +nvidia-cudnn-cu12==9.10.2.21 + # via torch +nvidia-cufft-cu12==11.3.3.83 + # via torch +nvidia-cufile-cu12==1.13.1.3 + # via torch +nvidia-curand-cu12==10.3.9.90 + # via torch +nvidia-cusolver-cu12==11.7.3.90 + # via torch +nvidia-cusparse-cu12==12.5.8.93 + # via + # nvidia-cusolver-cu12 + # torch +nvidia-cusparselt-cu12==0.7.1 + # via torch +nvidia-nccl-cu12==2.27.3 + # via torch +nvidia-nvjitlink-cu12==12.8.93 + # via + # nvidia-cufft-cu12 + # nvidia-cusolver-cu12 + # nvidia-cusparse-cu12 + # torch +nvidia-nvtx-cu12==12.8.90 + # via torch +packaging==25.0 + # via huggingface-hub +pfzy==0.3.4 + # via inquirerpy +prompt-toolkit==3.0.52 + # via inquirerpy +pyyaml==6.0.3 + # via huggingface-hub +requests==2.32.5 + # via huggingface-hub +safetensors==0.6.2 + # via timesfm (pyproject.toml) +setuptools==80.9.0 + # via triton +sympy==1.14.0 + # via torch +torch==2.8.0 + # via timesfm (pyproject.toml) +tqdm==4.67.1 + # via huggingface-hub +triton==3.4.0 + # via torch +typing-extensions==4.15.0 + # via + # huggingface-hub + # torch +urllib3==2.5.0 + # via requests +wcwidth==0.2.14 + # via prompt-toolkit From 39df49c3a0bc3dea89f6cacadc71335387c2e4f5 Mon Sep 17 00:00:00 2001 From: Rajat Sen Date: Tue, 7 Oct 2025 23:58:53 +0000 Subject: [PATCH 2/7] uv installation instructions --- pyproject.toml | 12 ++++----- requirements.txt | 65 +++--------------------------------------------- 2 files changed, 9 insertions(+), 68 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 715240b..36ce3fd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -23,12 +23,12 @@ torch = [ "torch>=2.0.0", ] flax = [ - "flax>=0.8.2", - "optax>=0.2.2", - "einshape>=0.8.0", - "orbax-checkpoint>=0.5.15", - "jaxtyping>=0.2.29", - "jax>=0.4.26", + "flax", + "optax", + "einshape", + "orbax-checkpoint", + "jaxtyping", + "jax[cuda12]" ] [tool.ruff] diff --git a/requirements.txt b/requirements.txt index 2b93766..e9e72b1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,13 +5,9 @@ certifi==2025.10.5 charset-normalizer==3.4.3 # via requests filelock==3.19.1 - # via - # huggingface-hub - # torch + # via huggingface-hub fsspec==2025.9.0 - # via - # huggingface-hub - # torch + # via huggingface-hub hf-xet==1.1.10 # via huggingface-hub huggingface-hub==0.35.3 @@ -20,53 +16,8 @@ idna==3.10 # via requests inquirerpy==0.3.4 # via huggingface-hub -jinja2==3.1.6 - # via torch -markupsafe==3.0.3 - # via jinja2 -mpmath==1.3.0 - # via sympy -networkx==3.5 - # via torch numpy==2.3.3 # via timesfm (pyproject.toml) -nvidia-cublas-cu12==12.8.4.1 - # via - # nvidia-cudnn-cu12 - # nvidia-cusolver-cu12 - # torch -nvidia-cuda-cupti-cu12==12.8.90 - # via torch -nvidia-cuda-nvrtc-cu12==12.8.93 - # via torch -nvidia-cuda-runtime-cu12==12.8.90 - # via torch -nvidia-cudnn-cu12==9.10.2.21 - # via torch -nvidia-cufft-cu12==11.3.3.83 - # via torch -nvidia-cufile-cu12==1.13.1.3 - # via torch -nvidia-curand-cu12==10.3.9.90 - # via torch -nvidia-cusolver-cu12==11.7.3.90 - # via torch -nvidia-cusparse-cu12==12.5.8.93 - # via - # nvidia-cusolver-cu12 - # torch -nvidia-cusparselt-cu12==0.7.1 - # via torch -nvidia-nccl-cu12==2.27.3 - # via torch -nvidia-nvjitlink-cu12==12.8.93 - # via - # nvidia-cufft-cu12 - # nvidia-cusolver-cu12 - # nvidia-cusparse-cu12 - # torch -nvidia-nvtx-cu12==12.8.90 - # via torch packaging==25.0 # via huggingface-hub pfzy==0.3.4 @@ -79,20 +30,10 @@ requests==2.32.5 # via huggingface-hub safetensors==0.6.2 # via timesfm (pyproject.toml) -setuptools==80.9.0 - # via triton -sympy==1.14.0 - # via torch -torch==2.8.0 - # via timesfm (pyproject.toml) tqdm==4.67.1 # via huggingface-hub -triton==3.4.0 - # via torch typing-extensions==4.15.0 - # via - # huggingface-hub - # torch + # via huggingface-hub urllib3==2.5.0 # via requests wcwidth==0.2.14 From 1c0cd87f2b92147ec7087afd9583a3310b3f2af8 Mon Sep 17 00:00:00 2001 From: Rajat Sen Date: Wed, 8 Oct 2025 00:06:52 +0000 Subject: [PATCH 3/7] updating workflows --- .github/workflows/main.yml | 2 +- .github/workflows/manual_publish.yml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6aa04b1..1d3c69b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -21,6 +21,6 @@ jobs: echo "$HOME/.cargo/bin" >> $GITHUB_PATH - name: Install build dependencies run: | - uv pip install build + uv pip install build ".[torch,flax]" - name: Build package run: python -m build \ No newline at end of file diff --git a/.github/workflows/manual_publish.yml b/.github/workflows/manual_publish.yml index 473a742..99f4bbd 100644 --- a/.github/workflows/manual_publish.yml +++ b/.github/workflows/manual_publish.yml @@ -16,9 +16,9 @@ jobs: run: | curl -LsSf https://astral.sh/uv/install.sh | sh echo "$HOME/.cargo/bin" >> $GITHUB_PATH - - name: Install Poetry + - name: Install Poetry and dependencies run: | - uv pip install poetry + uv pip install poetry ".[torch,flax]" - name: Build and Publish to PyPI run: | poetry config pypi-token.pypi ${{ secrets.PYPI_API_TOKEN }} From c172faf5eb28ac369e5b104350a8dcdcd477b817 Mon Sep 17 00:00:00 2001 From: Rajat Sen Date: Wed, 8 Oct 2025 00:14:50 +0000 Subject: [PATCH 4/7] yml file changes --- .github/workflows/main.yml | 2 ++ .github/workflows/manual_publish.yml | 2 ++ 2 files changed, 4 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 1d3c69b..ede52f6 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -19,6 +19,8 @@ jobs: run: | curl -LsSf https://astral.sh/uv/install.sh | sh echo "$HOME/.cargo/bin" >> $GITHUB_PATH + - name: Create virtual environment + run: uv venv - name: Install build dependencies run: | uv pip install build ".[torch,flax]" diff --git a/.github/workflows/manual_publish.yml b/.github/workflows/manual_publish.yml index 99f4bbd..0d17a4b 100644 --- a/.github/workflows/manual_publish.yml +++ b/.github/workflows/manual_publish.yml @@ -16,6 +16,8 @@ jobs: run: | curl -LsSf https://astral.sh/uv/install.sh | sh echo "$HOME/.cargo/bin" >> $GITHUB_PATH + - name: Create virtual environment + run: uv venv - name: Install Poetry and dependencies run: | uv pip install poetry ".[torch,flax]" From 604ad590674b8bfca96575ed21448a9224fe194e Mon Sep 17 00:00:00 2001 From: Rajat Sen Date: Wed, 8 Oct 2025 00:19:55 +0000 Subject: [PATCH 5/7] yml file changes --- .github/workflows/manual_publish.yml | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/.github/workflows/manual_publish.yml b/.github/workflows/manual_publish.yml index 0d17a4b..3cd30e9 100644 --- a/.github/workflows/manual_publish.yml +++ b/.github/workflows/manual_publish.yml @@ -18,10 +18,12 @@ jobs: echo "$HOME/.cargo/bin" >> $GITHUB_PATH - name: Create virtual environment run: uv venv - - name: Install Poetry and dependencies - run: | - uv pip install poetry ".[torch,flax]" - - name: Build and Publish to PyPI - run: | - poetry config pypi-token.pypi ${{ secrets.PYPI_API_TOKEN }} - poetry publish --build + - name: Install build dependencies + run: uv pip install build twine + - name: Build package + run: uv run python -m build + - name: Publish to PyPI + env: + TWINE_USERNAME: __token__ + TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} + run: uv run twine upload dist/* \ No newline at end of file From cae3104aa6a02d4c6f322cf3ff395299e1e861f1 Mon Sep 17 00:00:00 2001 From: Rajat Sen Date: Wed, 8 Oct 2025 00:21:25 +0000 Subject: [PATCH 6/7] yml file changes --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ede52f6..6bee2a1 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -25,4 +25,4 @@ jobs: run: | uv pip install build ".[torch,flax]" - name: Build package - run: python -m build \ No newline at end of file + run: uv run python -m build \ No newline at end of file From bf23fb4880447ba19b208d31dc5a9d1ffda57487 Mon Sep 17 00:00:00 2001 From: Rajat Sen Date: Wed, 8 Oct 2025 15:50:21 +0000 Subject: [PATCH 7/7] readme update and not pinning cuda versin for flax --- README.md | 7 +++++++ pyproject.toml | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9db8441..2d03cf9 100644 --- a/README.md +++ b/README.md @@ -64,6 +64,13 @@ will be under construction over the next few weeks to uv pip install -e .[flax] ``` +3. [Optional] Install your preferred `torch` / `jax` backend based on your OS and accelerators +(CPU, GPU, TPU or Apple Silicon).: + +- [Install PyTorch](https://pytorch.org/get-started/locally/). +- [Install Jax](https://docs.jax.dev/en/latest/installation.html#installation) + for Flax. + ### Code Example ```python diff --git a/pyproject.toml b/pyproject.toml index 36ce3fd..facfbdb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -28,7 +28,7 @@ flax = [ "einshape", "orbax-checkpoint", "jaxtyping", - "jax[cuda12]" + "jax[cuda]" ] [tool.ruff]