# geniescript
![Test](https://github.com/magland/geniescript/actions/workflows/test.yml/badge.svg)
A Python CLI tool that helps scientists and researchers generate and execute data processing scripts using AI language models. This tool simplifies the process of creating Python scripts for data analysis, transformation, and visualization tasks.
## Installation
```bash
pip install geniescript
```
## Usage
1. Set your OpenAI API key:
```bash
export OPENAI_API_KEY=your_api_key_here
```
2. Create a source file (e.g., `analysis.genie`) with instructions describing your data processing task.
3. Run the script:
```bash
geniescript run analysis.genie
```
The tool will:
- Generate a Python script based on your data processing instructions using AI
- Save the generated code to `analysis.genie.py`
- Execute the generated Python script
If you run the command again with the same instructions, it will skip the generation step and directly execute the existing Python script.
### Command Options
`--no-execute`: Generate the Python file without executing it. This is useful when you want to review or modify the generated code before processing your data.
```bash
geniescript run analysis.genie --no-execute
```
`--script-args`: Pass command line arguments to the generated Python script, such as input file paths or processing parameters. These arguments will be accessible via sys.argv in the generated script.
```bash
geniescript run analysis.genie --script-args="input_data.csv output_results.csv"
```
### Examples
1. Basic command output example:
```bash
# Create a script that uses system commands
echo "Create a Python script that uses the 'cat' command to output the first 10 prime numbers" > analysis.genie
# Run it
geniescript run analysis.genie
```
2. CSV processing with command-line arguments:
```bash
# Create a script to analyze data
echo "Create a Python script that processes CSV data. The script should:
- Read the input CSV file from the first command-line argument (sys.argv[1])
- Calculate basic statistics (mean, median, std) for each numeric column
- Save results to the output CSV file specified in the second argument (sys.argv[2])" > analyze.genie
# Run it with input/output file paths
geniescript run analyze.genie --script-args="experiment_data.csv stats_results.csv"
```
### System Files
You can include system files in your instructions using the special comment syntax:
```
// system path/to/system/file.txt
```
These files will be included in the system prompt for the AI model. This is useful for providing additional context about your data format, analysis requirements, or processing parameters. System files are also an excellent way to teach the AI about specific packages that are installed in your environment and how to use them effectively.
Raw data
{
"_id": null,
"home_page": "https://github.com/magland/geniescript",
"name": "geniescript",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.9",
"maintainer_email": null,
"keywords": "ai, llm, data-processing, scientific-computing, research-tools, code-generation",
"author": "Jeremy Magland",
"author_email": "jmagland@flatironinstitute.org",
"download_url": "https://files.pythonhosted.org/packages/e5/c3/d7ad93b7ac7beba05e4eec0acae582a5aa8a012e40ce13d97d1181a68c78/geniescript-0.1.1.tar.gz",
"platform": null,
"description": "# geniescript\n\n![Test](https://github.com/magland/geniescript/actions/workflows/test.yml/badge.svg)\n\nA Python CLI tool that helps scientists and researchers generate and execute data processing scripts using AI language models. This tool simplifies the process of creating Python scripts for data analysis, transformation, and visualization tasks.\n\n## Installation\n\n```bash\npip install geniescript\n```\n\n## Usage\n\n1. Set your OpenAI API key:\n```bash\nexport OPENAI_API_KEY=your_api_key_here\n```\n\n2. Create a source file (e.g., `analysis.genie`) with instructions describing your data processing task.\n\n3. Run the script:\n\n```bash\ngeniescript run analysis.genie\n```\n\nThe tool will:\n- Generate a Python script based on your data processing instructions using AI\n- Save the generated code to `analysis.genie.py`\n- Execute the generated Python script\n\nIf you run the command again with the same instructions, it will skip the generation step and directly execute the existing Python script.\n\n### Command Options\n\n`--no-execute`: Generate the Python file without executing it. This is useful when you want to review or modify the generated code before processing your data.\n```bash\ngeniescript run analysis.genie --no-execute\n```\n\n`--script-args`: Pass command line arguments to the generated Python script, such as input file paths or processing parameters. These arguments will be accessible via sys.argv in the generated script.\n```bash\ngeniescript run analysis.genie --script-args=\"input_data.csv output_results.csv\"\n```\n\n### Examples\n\n1. Basic command output example:\n```bash\n# Create a script that uses system commands\necho \"Create a Python script that uses the 'cat' command to output the first 10 prime numbers\" > analysis.genie\n\n# Run it\ngeniescript run analysis.genie\n```\n\n2. CSV processing with command-line arguments:\n```bash\n# Create a script to analyze data\necho \"Create a Python script that processes CSV data. The script should:\n- Read the input CSV file from the first command-line argument (sys.argv[1])\n- Calculate basic statistics (mean, median, std) for each numeric column\n- Save results to the output CSV file specified in the second argument (sys.argv[2])\" > analyze.genie\n\n# Run it with input/output file paths\ngeniescript run analyze.genie --script-args=\"experiment_data.csv stats_results.csv\"\n```\n\n### System Files\n\nYou can include system files in your instructions using the special comment syntax:\n```\n// system path/to/system/file.txt\n```\n\nThese files will be included in the system prompt for the AI model. This is useful for providing additional context about your data format, analysis requirements, or processing parameters. System files are also an excellent way to teach the AI about specific packages that are installed in your environment and how to use them effectively.\n",
"bugtrack_url": null,
"license": "Apache-2.0",
"summary": "A Python package for generating and executing data processing scripts using AI language models",
"version": "0.1.1",
"project_urls": {
"Homepage": "https://github.com/magland/geniescript",
"Repository": "https://github.com/magland/geniescript"
},
"split_keywords": [
"ai",
" llm",
" data-processing",
" scientific-computing",
" research-tools",
" code-generation"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "7659fa7dbad5f4fa952383200c211bffc5ab73df34a9ab14f431ec30b2e2b718",
"md5": "a0c6292dd66a8dfe682f2ce0bd0a053d",
"sha256": "46f41183c692c82591ef9179e21d509bedf39083878491997ec4a372e4470c2b"
},
"downloads": -1,
"filename": "geniescript-0.1.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "a0c6292dd66a8dfe682f2ce0bd0a053d",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.9",
"size": 11688,
"upload_time": "2024-12-11T21:17:14",
"upload_time_iso_8601": "2024-12-11T21:17:14.980643Z",
"url": "https://files.pythonhosted.org/packages/76/59/fa7dbad5f4fa952383200c211bffc5ab73df34a9ab14f431ec30b2e2b718/geniescript-0.1.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "e5c3d7ad93b7ac7beba05e4eec0acae582a5aa8a012e40ce13d97d1181a68c78",
"md5": "9aeaa1e65e0cbc9bfaddc82a2f60bdff",
"sha256": "e6702a2ad6ba107fe4a75c573308feac07f9318041a145da32d94a762cd9faac"
},
"downloads": -1,
"filename": "geniescript-0.1.1.tar.gz",
"has_sig": false,
"md5_digest": "9aeaa1e65e0cbc9bfaddc82a2f60bdff",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.9",
"size": 9758,
"upload_time": "2024-12-11T21:17:17",
"upload_time_iso_8601": "2024-12-11T21:17:17.079275Z",
"url": "https://files.pythonhosted.org/packages/e5/c3/d7ad93b7ac7beba05e4eec0acae582a5aa8a012e40ce13d97d1181a68c78/geniescript-0.1.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-11 21:17:17",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "magland",
"github_project": "geniescript",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "geniescript"
}