Skip to content

Commit

Permalink
Add linter and lint existing files
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanleung committed Nov 8, 2024
1 parent 8461cc6 commit 33a3206
Show file tree
Hide file tree
Showing 97 changed files with 1,051 additions and 931 deletions.
43 changes: 41 additions & 2 deletions .flake8
Original file line number Diff line number Diff line change
@@ -1,4 +1,43 @@
[flake8]
max-line-length = 100
exclude = .git,__pycache__,build,dist,*.egg-info
ignore = E203, W503, E731
max-complexity = 10
exclude =
.git,
__pycache__,
build,
dist,
*.egg-info,
venv,
.venv
extend-ignore =
# Black conflicts with E203 (whitespace before ':')
E203,
# Line break before binary operator (Black formats this way)
W503,
# Lambda assignments (used in routes)
E731,
# Bugbear errors that might cause recursion
B023,
# Ignore nested function definition
B006,
# Ignore missing docstring in public module/package/class/function/method
D100,
D101,
D104,
D102,
D103,
D105,
D106,
D107,

per-file-ignores =
# Allow unused imports in __init__.py
__init__.py: F401
# Allow longer lines in config files
config.py: E501

# Limit the plugins to avoid recursion issues
enable-extensions = B

# Increased recursion depth adjustment for bugbear
max-recursion-depth = 1000
16 changes: 2 additions & 14 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,14 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: '20'

- name: Install Python linting dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 black isort mypy
pip install flake8 black isort
pip install -r requirements.txt
- name: Install Node.js linting dependencies
working-directory: ./submodules/moragents_dockers/frontend
run: |
npm install --save-dev eslint @typescript-eslint/parser @typescript-eslint/eslint-plugin
- name: Run Python linters
run: |
flake8 .
black . --check
isort . --check-only
mypy .
- name: Run JavaScript/TypeScript linters
working-directory: ./submodules/moragents_dockers/frontend
run: |
npx eslint . --ext .js,.jsx,.ts,.tsx
4 changes: 2 additions & 2 deletions .github/workflows/mor-agents-build-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ jobs:
local model=\$1
local max_attempts=3
local attempt=1
while [ \$attempt -le \$max_attempts ]; do
echo -e "\${YELLOW}Pulling Ollama model \$model (Attempt \$attempt)...${NC}"
if ollama pull \$model; then
Expand All @@ -115,7 +115,7 @@ jobs:
sleep 5
attempt=\$((attempt + 1))
done
echo -e "\${RED}Failed to pull \$model after \$max_attempts attempts.${NC}"
return 1
}
Expand Down
18 changes: 9 additions & 9 deletions .github/workflows/mor-agents-build-mac-arm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,45 +10,45 @@ on:
jobs:
build:
runs-on: macos-latest

steps:
- uses: actions/checkout@v4
with:
submodules: 'recursive'

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pyinstaller
- name: Build with PyInstaller
run: |
pyinstaller --windowed --name="MORagents" --icon="images/moragents.icns" --osx-entitlements-file "build_assets/macOS/MORagents.entitlements" main.py
- name: Move .app to expected location
run: |
mv dist/MORagents.app build_assets/macOS/
- name: Install Packages app
run: |
wget http://s.sudre.free.fr/files/Packages_1211_dev.dmg
hdiutil attach Packages_1211_dev.dmg
sudo installer -pkg /Volumes/Packages\ 1.2.11/packages/Packages.pkg -target /
hdiutil detach /Volumes/Packages\ 1.2.11
- name: Create installer package
run: |
cd build_assets/macOS
/usr/local/bin/packagesbuild --verbose --project MorpheusPackagesSudre.pkgproj
- name: Upload Installer
uses: actions/upload-artifact@v4
with:
name: MORagentsSetup-macOS
path: ./build_assets/macOS/MORAgentsInstaller.pkg
path: ./build_assets/macOS/MORAgentsInstaller.pkg
18 changes: 9 additions & 9 deletions .github/workflows/mor-agents-build-mac-intel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,45 +10,45 @@ on:
jobs:
build:
runs-on: macos-latest

steps:
- uses: actions/checkout@v4
with:
submodules: 'recursive'

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pyinstaller
- name: Build with PyInstaller
run: |
pyinstaller --windowed --name="MORagents" --icon="images/moragents.icns" --osx-entitlements-file "build_assets/macOS/MORagents.entitlements" main.py
- name: Move .app to expected location
run: |
mv dist/MORagents.app build_assets/macOS/
- name: Install Packages app
run: |
wget http://s.sudre.free.fr/files/Packages_1211_dev.dmg
hdiutil attach Packages_1211_dev.dmg
sudo installer -pkg /Volumes/Packages\ 1.2.11/packages/Packages.pkg -target /
hdiutil detach /Volumes/Packages\ 1.2.11
- name: Create installer package
run: |
cd build_assets/macOS
/usr/local/bin/packagesbuild --verbose --project MorpheusPackagesSudreIntel.pkgproj
- name: Upload Installer
uses: actions/upload-artifact@v4
with:
name: MORagentsSetup-macOS
path: ./build_assets/macOS/MORAgentsInstaller.pkg
path: ./build_assets/macOS/MORAgentsInstaller.pkg
2 changes: 1 addition & 1 deletion .github/workflows/mor-agents-build-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
jobs:
build:
runs-on: windows-latest

steps:
- uses: actions/checkout@v4

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/security_scan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ jobs:
- name: Upload Trivy scan results
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: 'trivy-results.sarif'
sarif_file: 'trivy-results.sarif'
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,4 @@ MORagentsWindowsInstaller.zip
MORagents.app

## lint
.mypy_cache/
.pytest_cache/
25 changes: 0 additions & 25 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,3 @@ repos:
rev: 5.13.2
hooks:
- id: isort

- repo: https://github.com/pycqa/flake8
rev: 7.0.0
hooks:
- id: flake8
additional_dependencies: [
'flake8-bugbear',
'flake8-comprehensions',
'flake8-docstrings',
]

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.8.0
hooks:
- id: mypy
additional_dependencies: [types-all]

- repo: local
hooks:
- id: eslint
name: eslint
entry: bash -c 'cd submodules/moragents_dockers/frontend && npx eslint'
language: system
types_or: [javascript, jsx, ts, tsx]
require_serial: true
14 changes: 7 additions & 7 deletions AGENTABILITIES.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# MORagents
Welcome to the world of Web3 agents! If you're interested in building and using agents locally, this document will guide you through the principles and
Welcome to the world of Web3 agents! If you're interested in building and using agents locally, this document will guide you through the principles and
current projects underway.

### Principles:
1. **Agents cannot execute decisions**: Agents should not be given private keys or allowed to make transactions on their own. They can only construct transaction
1. **Agents cannot execute decisions**: Agents should not be given private keys or allowed to make transactions on their own. They can only construct transaction
payloads for a user's approval. This is due to the limitations of current LLMs in understanding complex transactions and the risk of [gaslighting](https://arxiv.org/abs/2311.04235).
2. **Local installation**: Agents should run on the user's laptop, typically with 8-16 GB of RAM. This allows for faster execution and better performance.
3. **No private keys**: Agents must not have access to private keys or be able to execute transactions independently. User's cryptographic approval is essential for any
3. **No private keys**: Agents must not have access to private keys or be able to execute transactions independently. User's cryptographic approval is essential for any
transaction.

### Current Projects:
1. **lachsbagel on Discord** - [this repo](https://github.com/MorpheusAIs/moragents):
1. **lachsbagel on Discord** - [this repo](https://github.com/MorpheusAIs/moragents):
1. Architecture
2. **IODmitri, SanatSharma, LachsBagel on GitHhub**
1. [HideNSeek](https://github.com/MorpheusAIs/HideNSeek): An algorithm for verifying and fingerprinting which model a compute provider is actually running
Expand All @@ -25,10 +25,10 @@ transaction.
4. CICD builds for Linux and macOS (apple and intel)
5. Vulnerability scanning of dependencies and code
4. GenLayer
1. (pending) [FeedBuzz](https://github.com/yeagerai/feedbuzz-contracts) - AI filtered logging system to surface user demand and failure modes for new functionality
1. (pending) [FeedBuzz](https://github.com/yeagerai/feedbuzz-contracts) - AI filtered logging system to surface user demand and failure modes for new functionality
5. **CliffordAttractor on Discord** - Following Assume 16GB+ RAM:
1. Developed a [price fetcher agent](submodules/moragents_dockers/agents/src/data_agent) using CoinGecko.
2. A [web interface](submodules/moragents_dockers/frontend) which is served by the local Docker installation and integrated with Rainbow, enabling the use of MetaMask, WalletConnect, and other
2. A [web interface](submodules/moragents_dockers/frontend) which is served by the local Docker installation and integrated with Rainbow, enabling the use of MetaMask, WalletConnect, and other
EVM-based wallets.
3. (NEEDS REFACTORING DUE TO 1INCH CHANGE) [Swap agent](submodules/moragents_dockers/agents/src/swap_agent) which can iteratively ask users to provide needed details for disambiguation.
4. [General-purpose agent](https://github.com/MorpheusAIs/moragents/pull/34) that can ingest arbitrary documents, such as PDFs, for basic document QA and text generation.
Expand Down Expand Up @@ -57,7 +57,7 @@ Pending Lumerin's work. Eventually Agent Builders will be able to permission-les


### How to Contribute:
- If you are working on an agent which can provide value through open models and relies on processing public data, please reach out to lachsbagel on Discord (link below)
- If you are working on an agent which can provide value through open models and relies on processing public data, please reach out to lachsbagel on Discord (link below)
- Otherwise, you are more than welcome to publish your agent to the registry when it goes live pending Lumerin's work and any other necessary pieces which come up to better ensure security and verifiability of models in non-local execution environments.
- If you are working on security and/or verifiability of models and the runtime, please reach out to LachsBagel on the Morpheus Discord.
- Currently looking at [Hyperbolic.xyz](https://hyperbolic.xyz) and [6079](https://docs.6079.ai/technology/6079-proof-of-inference-protocol). See more ecosystem members [here](https://mor.org/ecosystem).
Expand Down
2 changes: 1 addition & 1 deletion DISCLAIMER.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
This highly experimental chatbot is not intended for making important decisions, and its responses are generated based on incomplete data and algorithms that may evolve
This highly experimental chatbot is not intended for making important decisions, and its responses are generated based on incomplete data and algorithms that may evolve
rapidly. By using this chatbot, you acknowledge that you use it at your own discretion and assume all risks associated with its limitations and potential errors.
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Fully Extensible! Add your own agents and have them automatically invoked based
#### Steps to Install
1. Download Installer
1. For Mac on Apple Silicon M1/2/3 etc. (arm64)
1. For Mac on Apple Silicon M1/2/3 etc. (arm64)
1. Download and run MORagents installer [MORagents020-apple.pkg](https://drive.proton.me/urls/20ENWS94AW#Kols2sA9mWLf)
> SHA256 e65e11719a24ca9a00545443a35cda3b6d78f756b8e2ba535db00399ef75168f MORagents020-apple.pkg
2. For Mac on Intel (x86_64)
Expand All @@ -52,11 +52,11 @@ Fully Extensible! Add your own agents and have them automatically invoked based
#### Future Usage
- Open the "MORagents" app from Mac search bar.
- For easier access: Right-click MORagents icon on dock -> Options -> Keep in Dock
- For easier access: Right-click MORagents icon on dock -> Options -> Keep in Dock

#### Troubleshooting
- If the app shows connections errors in connecting to agents. Please ensure Docker Desktop is running, then close and reopen **MORagents** from desktop.
- If installation is unsuccessful, run the following in your Terminal and open the MORagents....pkg again
- If installation is unsuccessful, run the following in your Terminal and open the MORagents....pkg again
```shell
$ xcode-select --install
```
Expand All @@ -74,7 +74,7 @@ Fully Extensible! Add your own agents and have them automatically invoked based
2. If that still doesn't work, try temporarily disabling your antivirus and open the .exe again
4. Click and Run **MORagentsSetup.exe**
1. This will auto-install Docker and Ollama dependencies. Those will ask you for confirmation.
5. Open **MORagents** from Desktop
5. Open **MORagents** from Desktop
1. Wait for Docker engine to start...
2. If you see any errors or if anything hangs for >10min, please try opening the MORagents app again from the Desktop

Expand All @@ -100,4 +100,3 @@ This will allow you to add custom agents which will be automatically invoked bas
#### Build instructions:
1. [macOS](build_assets/macOS/README_MACOS_DEV_BUILD.md)
2. [Windows](build_assets/windows/README_WINDOWS_DEV_BUILD.md)

2 changes: 1 addition & 1 deletion build_assets/linux/install_moragents.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ echo -e "${YELLOW}Running MORagents setup...${NC}"

echo -e "${GREEN}Installation complete!${NC}"
echo "You can now start MORagents from your application menu or by running 'MORagents' in the terminal."
echo -e "${YELLOW}NOTE: Please log out and log back in for Docker group changes to take effect.${NC}"
echo -e "${YELLOW}NOTE: Please log out and log back in for Docker group changes to take effect.${NC}"
14 changes: 7 additions & 7 deletions build_assets/macOS/Packaging_Instructions_macOS.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ NOTE: you will need to use your own codesigning identity if you intend to distri
2. Under the Packages, either edit the existing package or create a new one. Set "Identifier" to com.morpheus.pkg.MORAgents, set the Payload to have MORAgents.app under /Applications, then under Scripts, add the preinstall.sh and postinstall.sh from the downloaded files.\
3. Create a new Package, Set "Identifier" to com.morpheus.pkg.DockerDesktop, then under Payload, add the Docker Desktop Mac Install under /Applications\
4. Create a new Package, Set "Identifier" to com.morpheus.pkg.Ollama, then under preinstall scripts, add the preinstall_ollama.sh script from the downloaded files.\
5. Navigate to Project, then in Presentation click the topright dropdown and select Introduction choose the welcome.html file, add a License section and choose license.html.
5. Navigate to Project, then in Presentation click the topright dropdown and select Introduction choose the welcome.html file, add a License section and choose license.html.
6. In the upmost toolbar click Build -> Build to generate a .pkg file in the directory you saved the MORagents Packages package

---
Expand All @@ -27,17 +27,17 @@ Future usage only requires you to run MORagents from your searchbar.
---

## Signing
```sh
```sh
productsign --sign "Developer ID Installer: Liquid Tensor LLC (ZQN244GMTD)" MORagents.pkg MORagents010-[apple\|intel].pkg
```

## Notarize
```sh
## Notarize
```sh
xcrun notarytool submit MORagents020-[apple\|intel].pkg --keychain-profile "NotaryProfile" --wait
```

## Staple
```sh
```sh
xcrun stapler staple MORagents020-[apple\|intel].pkg
```

Expand All @@ -47,12 +47,12 @@ xcrun stapler staple MORagents020-[apple\|intel].pkg

### Verify notarization
```sh
xcrun notarytool info "<submission id>" --keychain-profile "NotaryProfile"
xcrun notarytool info "<submission id>" --keychain-profile "NotaryProfile"
```

### Verify codesign
```sh
codesign --verify --verbose=4 MORagents.app

codesign -dv --verbose=4 MORagents.app
```
```
Loading

0 comments on commit 33a3206

Please sign in to comment.