Skip to content

Commit

Permalink
v0.2.31: Fixed environment variable handling in Config class
Browse files Browse the repository at this point in the history
  • Loading branch information
tomaslau committed Nov 25, 2024
1 parent f83aad0 commit 8a2189e
Show file tree
Hide file tree
Showing 5 changed files with 110 additions and 27 deletions.
14 changes: 7 additions & 7 deletions .cursorrules
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ Something like Zapier/n8n but for local machines.

## Key Features

- 🚀 Start small, ship fast
- 🔌 Easy API connections to your existing tools
- 🤖 AI-first but not AI-only
- 📦 Zero bloat, minimal dependencies
- 🛠 Built for real marketing workflows
- Quick to prototype and iterate
- 🌐 Local-first, no cloud dependencies
- Start small, ship fast
- Easy API connections to your existing tools
- AI-first but not AI-only
- Zero bloat, minimal dependencies
- Built for real marketing workflows
- Quick to prototype and iterate
- Local-first, no cloud dependencies

## Technology

Expand Down
41 changes: 40 additions & 1 deletion docs/changelog.md
Original file line number Diff line number Diff line change
@@ -1,45 +1,75 @@
---
title: "Changelog"
publishedAt: "2024-11-03"
updatedAt: "2024-11-24"
updatedAt: "2024-11-25"
summary: "Updates, bug fixes and improvements."
kind: "detailed"
---

## v0.2.31 - Nov 25, 2024

### Fixed

- Environment variable handling in Config class
- Added proper os.getenv() check in config.get()
- Fixed API key loading from .env files
- Improved error messages for missing keys
- Maintained backward compatibility

### Changed

- Enhanced configuration management
- Simplified environment variable access
- Improved error handling for missing API keys
- Added better debugging support
- Updated documentation with clear examples

### Documentation

- Updated debugging guide with environment troubleshooting
- Added clear examples for API key configuration
- Improved error message documentation

## v0.2.30 - Nov 24, 2024

### Changed

- Updated version number in setup.py and `__init__.py`

## v0.2.29 - Nov 24, 2024

### Changed

- Updated package installation to include complete project structure
- Modified setup.py to create WordPress-like installation experience
- Updated MANIFEST.in to include all project files
- Improved installation process to copy workflows, docs, and configuration files

### Added

- Complete project scaffold during installation
- Example workflows ready to use after installation
- Documentation and configuration files included in package

## v0.2.28 - Nov 24, 2024

### Changed

- Updated package installation to include complete project structure
- Modified setup.py to create WordPress-like installation experience
- Updated MANIFEST.in to include all project files
- Improved installation process to copy workflows, docs, and configuration files

### Added

- Complete project scaffold during installation
- Example workflows ready to use after installation
- Documentation and configuration files included in package

## v0.2.27 - Nov 23, 2024

### Changed

- Enhanced configuration management
- Moved `.env` and `pynions.json` to project root
- Removed nested config directory structure
Expand All @@ -60,6 +90,7 @@ kind: "detailed"
- Simplified example workflow code

### Added

- New configuration methods:
- `set()` for runtime configuration
- `clear()` for resetting state
Expand All @@ -68,21 +99,25 @@ kind: "detailed"
- Type hints for better IDE support

### Fixed

- Environment variable handling in tests
- Configuration inheritance issues
- Missing type hints
- Inconsistent model defaults across codebase

### Security

- Improved API key management
- Enhanced environment variable handling

### Performance

- Standardized on gpt-4o-mini for better cost-performance ratio

## v0.2.26 - Nov 22, 2024

### Changed

- Simplified configuration management system
- Moved configuration files to project root
- Removed nested config folder structure
Expand All @@ -91,21 +126,25 @@ kind: "detailed"
- Enhanced error handling and output formatting

### Added

- Root-level `.env` for API keys
- Root-level `pynions.json` for settings
- Clearer setup instructions in installation
- Example file copying during installation

### Removed

- Complex nested configuration system
- ~/.pynions directory requirement
- Outdated example configurations

### Security

- Improved API key management
- Enhanced environment variable handling

### Dependencies

- Updated minimum Python version to 3.8+

## v0.2.25 - Nov 20, 2024
Expand Down
2 changes: 1 addition & 1 deletion pynions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from pynions.core import Plugin, Workflow, WorkflowStep, Config, DataStore, Worker

__version__ = "0.2.30"
__version__ = "0.2.31"

__all__ = [
# Core components
Expand Down
9 changes: 8 additions & 1 deletion pynions/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import json
from typing import Any, Dict


class Config:
"""Minimal configuration management"""

Expand All @@ -29,7 +30,12 @@ def load_json(self, config_path: Path) -> None:
self._settings.update(json.load(f))

def get(self, key: str, default: Any = None) -> Any:
"""Get a configuration value"""
"""Get a configuration value from env or settings"""
# First check environment variables
env_value = os.getenv(key)
if env_value is not None:
return env_value
# Then check settings dictionary
return self._settings.get(key, default)

def set(self, key: str, value: Any) -> None:
Expand Down Expand Up @@ -57,6 +63,7 @@ def _load(self, root_dir: Path = None) -> None:

self.load(env_path, config_path)


# Global instance
config = Config()
config._load()
71 changes: 54 additions & 17 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,27 @@ def run(self):

# Get package directory
pkg_dir = Path(__file__).parent

# Get installation directory (where user ran pip install)
install_dir = Path.cwd()

# Files to copy
core_dirs = ['pynions', 'workflows', 'docs', 'tests', 'data']
core_dirs = ["pynions", "workflows", "docs", "tests", "data"]
config_files = [
('.env.example', '.env'),
('pynions.example.json', 'pynions.json'),
('README.md', 'README.md'),
('requirements.txt', 'requirements.txt'),
('pytest.ini', 'pytest.ini')
(".env.example", ".env"),
("pynions.example.json", "pynions.json"),
("README.md", "README.md"),
("requirements.txt", "requirements.txt"),
("pytest.ini", "pytest.ini"),
]

# Copy core directories
for dir_name in core_dirs:
src_dir = pkg_dir / dir_name
dst_dir = install_dir / dir_name
if src_dir.exists() and not dst_dir.exists():
shutil.copytree(src_dir, dst_dir)

# Copy config files
for src_name, dst_name in config_files:
src = pkg_dir / src_name
Expand All @@ -66,7 +66,7 @@ def run(self):

setup(
name="pynions",
version="0.2.30",
version="0.2.31",
author="Tomas Laurinavicius",
author_email="[email protected]",
description="Simple marketing automation framework",
Expand All @@ -85,15 +85,52 @@ def run(self):
"../pynions.example.json",
"../README.md",
"../requirements.txt",
"../pytest.ini"
"../pytest.ini",
],
},
data_files=[
(".", [".env.example", "pynions.example.json", "README.md", "requirements.txt", "pytest.ini"]),
("workflows", ["workflows/example_workflow.py", "workflows/content_analysis_workflow.py", "workflows/research_workflow.py", "workflows/alternatives_writer.py"]),
("docs", [f"docs/{f}" for f in ["changelog.md", "configuration.md", "data-organization.md", "debugging.md", "index.md", "installation.md", "nav.json", "plugins.md", "project-structure.md", "quickstart.md", "testing.md", "workers.md", "workflows.md"]]),
("data", ["data/air.md"]),
("tests", ["tests/test_config.py"])
(
".",
[
".env.example",
"pynions.example.json",
"README.md",
"requirements.txt",
"pytest.ini",
],
),
(
"workflows",
[
"workflows/example_workflow.py",
"workflows/content_analysis_workflow.py",
"workflows/research_workflow.py",
"workflows/alternatives_writer.py",
],
),
(
"docs",
[
f"docs/{f}"
for f in [
"changelog.md",
"configuration.md",
"data-organization.md",
"debugging.md",
"index.md",
"installation.md",
"nav.json",
"plugins.md",
"project-structure.md",
"quickstart.md",
"testing.md",
"workers.md",
"workflows.md",
]
],
),
("data", []),
("tests", ["tests/test_config.py"]),
],
install_requires=requirements,
cmdclass={
Expand Down

0 comments on commit 8a2189e

Please sign in to comment.