Skip to content

Commit

Permalink
🚜 Refactors justfiles to add module support
Browse files Browse the repository at this point in the history
  • Loading branch information
jefftriplett committed Sep 16, 2024
1 parent 025bcc4 commit 628c1f6
Show file tree
Hide file tree
Showing 10 changed files with 85 additions and 45 deletions.
7 changes: 6 additions & 1 deletion home/.justfiles/llm.justfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
# ----------------------------------------------------------------
# llm - https://virtualenv.pypa.io/en/latest/
# llm recipes - https://virtualenv.pypa.io/en/latest/
# ----------------------------------------------------------------

justfile := justfile_directory() + "/.justfiles/llm.justfile"

@_default:
just --list

@_fmt:
just --fmt --justfile {{ justfile }}

@install:
llm install llm-claude
llm install llm-ollama
Expand Down
22 changes: 15 additions & 7 deletions home/.justfiles/macos.justfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,41 @@
# macOS recipes
# ----------------------------------------------------------------

justfile := justfile_directory() + "/.justfiles/macos.justfile"

@_default:
just --list

@_fmt:
just --fmt --justfile {{ justfile }}

# ----------------------------------------------------------------
# Time Machine recipes
# ----------------------------------------------------------------

@macos-timemachine-boost:
@timemachine-boost:
# bump IO priority to finish more quickly
# https://apple.stackexchange.com/questions/382772/time-machine-in-the-cleaning-up-state-forever

sudo sysctl debug.lowpri_throttle_enabled=0

@macos-timemachine-boost-complete:
@timemachine-boost-complete:
# once done
sudo sysctl debug.lowpri_throttle_enabled=1

@macos-timemachine-delete *ARGS:
@timemachine-delete *ARGS:
sudo tmutil delete {{ ARGS }}

@macos-timemachine-list:
@timemachine-list:
sudo tmutil listbackups

# ----------------------------------------------------------------
# Xcode
# ----------------------------------------------------------------

@_macos-xcode-bootstrap:
@xcode-bootstrap:
sudo xcode-select --install

@macos-xcode-upgrade:
@xcode-upgrade:
sudo rm -rf /Library/Developer/CommandLineTools
just _xcode-bootstrap
just xcode-bootstrap
22 changes: 15 additions & 7 deletions home/.justfiles/ollama.justfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,25 @@
# Ollama recipes
# ----------------------------------------------------------------

justfile := justfile_directory() + "/.justfiles/ollama.justfile"

export OLLAMA_HOST := "0.0.0.0:11434"
export OLLAMA_KEEP_ALIVE := "30m"
export OLLAMA_ORIGINS := "http://*"

@ollama-copy-plist:
@_default:
just --list

@_fmt:
just --fmt --justfile {{ justfile }}

@copy-plist:
cp ~/.plists/homebrew.mxcl.ollama.plist /opt/homebrew/opt/ollama/homebrew.mxcl.ollama.plist

@ollama-diff-plist:
@diff-plist:
diff ~/.plists/homebrew.mxcl.ollama.plist /opt/homebrew/opt/ollama/homebrew.mxcl.ollama.plist

@ollama-download:
@download:
# https://github.com/jmorganca/ollama/blob/main/docs/modelfile.md#valid-parameters-and-values
# https://github.com/jmorganca/ollama/blob/main/examples/python/client.py
# https://github.com/jmorganca/ollama/pull/405/files#diff-7f12e314e14b1321e41971e2e84a07a9e200b99b6ecac2a5c7a6b98d887f3305
Expand All @@ -39,18 +47,18 @@ export OLLAMA_ORIGINS := "http://*"
-ollama pull orca2:latest
-ollama pull wizard-vicuna:latest

@ollama-list:
@list:
ollama list

@ollama-getenv:
@getenv:
launchctl getenv OLLAMA_HOST
launchctl getenv OLLAMA_KEEP_ALIVE
launchctl getenv OLLAMA_ORIGINS

@ollama-serve *ARGS:
@serve *ARGS:
tandem 'ollama serve {{ ARGS }}'

@ollama-setenv:
@setenv:
launchctl setenv OLLAMA_HOST {{ OLLAMA_HOST }}
launchctl setenv OLLAMA_KEEP_ALIVE {{ OLLAMA_KEEP_ALIVE }}
launchctl setenv OLLAMA_ORIGINS {{ OLLAMA_ORIGINS }}
20 changes: 14 additions & 6 deletions home/.justfiles/virtualenv.justfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
# ----------------------------------------------------------------
# virtualenv - https://virtualenv.pypa.io/en/latest/
# virtualenv recipes - https://virtualenv.pypa.io/en/latest/
# ----------------------------------------------------------------

virtualenv-scan:
justfile := justfile_directory() + "/.justfiles/virtualenv.justfile"

@_default:
just --list

@_fmt:
just --fmt --justfile {{ justfile }}

scan:
#!/usr/bin/env python
import subprocess
from pathlib import Path
Expand All @@ -23,7 +31,7 @@ virtualenv-scan:
except FileNotFoundError as e:
pass

@virtualenv-upgrade:
@upgrade:
for filename in $(ls -d ~/.virtualenvs/*/); do \
echo "$filename"; \
$filename/bin/python --version; \
Expand All @@ -36,12 +44,12 @@ virtualenv-scan:
# https://stackoverflow.com/questions/44692668/python-how-can-i-update-python-version-in-pyenv-virtual-environment

# pip freeze > requirements.lock
# pyenv virtualenv-delete a-virtualenv-name
# pyenv virtualenv 3.9.0 a-virtualenv-name
# pyenv delete a-name
# pyenv virtualenv 3.9.0 a-name
# pip install -r requirements.lock
# rm requirements.lock

@virtualenv-workon:
@workon:
for filename in $(ls -d ~/.virtualenvs/*/); do \
echo "$filename"; \
$filename/bin/python --version; \
Expand Down
42 changes: 27 additions & 15 deletions home/.justfiles/virtualenvwrapper.justfile
Original file line number Diff line number Diff line change
@@ -1,65 +1,77 @@
# ----------------------------------------------------------------
# virtualenvwrapper
# virtualenvwrapper recipes
# ----------------------------------------------------------------

_get_env_details:
justfile := justfile_directory() + "/.justfiles/virtualenvwrapper.justfile"

@_default:
just --list

@_fmt:
just --fmt --justfile {{ justfile }}

# ----------------------------------------------------------------
# virtualenvwrapper hooks
# ----------------------------------------------------------------

get_env_details:
#!/usr/bin/env sh
rich --print "[green]get_env_details[/green]"

_initialize:
initialize:
#!/usr/bin/env sh
rich --print "[green]initialize[/green]"

_postactivate:
postactivate:
#!/usr/bin/env sh
VIRTUAL_ENV_NAME=$(basename "${VIRTUAL_ENV}")
rich --print "[green]postactivate[/green]"

_postdeactivate:
postdeactivate:
#!/usr/bin/env sh
# VIRTUAL_ENV_NAME=$(basename "${VIRTUAL_ENV}")
rich --print "[green]postdeactivate[/green]"

_postmkproject:
postmkproject:
#!/usr/bin/env sh
rich --print "[green]postmkproject[/green]"

_postmkvirtualenv:
postmkvirtualenv:
#!/usr/bin/env sh
rich --print "[green]postmkvirtualenv[/green]"
python -m pip install --upgrade pip
python -m pip install --upgrade pip-tools
python -m pip install --upgrade uv

_postrmproject:
postrmproject:
#!/usr/bin/env sh
rich --print "[green]postrmproject[/green]"

_postrmvirtualenv:
postrmvirtualenv:
#!/usr/bin/env sh
rich --print "[green]postrmvirtualenv[/green]"

_preactivate:
preactivate:
#!/usr/bin/env sh
# VIRTUAL_ENV_NAME=$(basename "${VIRTUAL_ENV}")
rich --print "[green]preactivate[/green]"

_predeactivate:
predeactivate:
#!/usr/bin/env sh
rich --print "[green]predeactivate[/green]"

_premkproject:
premkproject:
#!/usr/bin/env sh
rich --print "[green]premkproject[/green]"

_premkvirtualenv:
premkvirtualenv:
#!/usr/bin/env sh
rich --print "[green]premkvirtualenv[/green]"

_prermproject:
prermproject:
#!/usr/bin/env sh
rich --print "[green]prermproject[/green]"

_prermvirtualenv:
prermvirtualenv:
#!/usr/bin/env sh
rich --print "[green]prermvirtualenv[/green]"
2 changes: 1 addition & 1 deletion home/.virtualenvs/postactivate
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,4 @@ fi
# figurine "${VIRTUAL_ENV_NAME}"
# fi

just --justfile=${HOME}/justfile _postactivate
just --justfile=${HOME}/justfile virtualenvwrapper::postactivate
2 changes: 1 addition & 1 deletion home/.virtualenvs/postdeactivate
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ if ! [ -e tabset ]; then
tabset --title ""
fi

just --justfile=${HOME}/justfile _postdeactivate
just --justfile=${HOME}/justfile virtualenvwrapper::postdeactivate
2 changes: 1 addition & 1 deletion home/.virtualenvs/postmkvirtualenv
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
# This hook is run after a new virtualenv is activated.

just --justfile=${HOME}/justfile _postmkvirtualenv
just --justfile=${HOME}/justfile virtualenvwrapper::postmkvirtualenv

# python -m pip install --upgrade pip
# python -m pip install --upgrade pip-tools
2 changes: 1 addition & 1 deletion home/.virtualenvs/preactivate
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
# This hook is run before every virtualenv is activated.

just --justfile=${HOME}/justfile _preactivate
just --justfile=${HOME}/justfile virtualenvwrapper::preactivate
9 changes: 4 additions & 5 deletions home/justfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ set export := true
export JUST_UNSTABLE := "true"

mod llm '.justfiles/llm.justfile'

import '.justfiles/macos.justfile'
import '.justfiles/ollama.justfile'
import '.justfiles/virtualenv.justfile'
import '.justfiles/virtualenvwrapper.justfile'
mod macos '.justfiles/macos.justfile'
mod ollama '.justfiles/ollama.justfile'
mod virtualenv '.justfiles/virtualenv.justfile'
mod virtualenvwrapper '.justfiles/virtualenvwrapper.justfile'

# export HOMEBREW_NO_AUTO_UPDATE := "true"

Expand Down

0 comments on commit 628c1f6

Please sign in to comment.