Coder Social home page Coder Social logo

duopoly's People

Contributors

atroche avatar duopoly avatar reitzensteinm avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

atroche

duopoly's Issues

Create Recipes File

Create a recipes.py file, which contains a Recipe data class containing:

  • An ID
  • A description
  • A prompt

There should be a function to instantiate a Recipe, and this should add it to a global list.

Add partition by predicate function

Add a function to partition a sequence by predicate. For instance if I start with [2,1,1,2,3,4,1,6] it turns into [[2,1,1],[2,3],[4,1][6]] based on the predicate 'is even'.

Fix duplicate main call in main.py

The main function is called twice in main.py - once that propagates the retries count, and once that does not. Remove the old one which does not.

Change To Force Push

In repo.py, change the push_local_branch_to_origin function to use the force push flag.

Test Issue #2

Please rename the main function to main2 and replace all occurences.

Move Patch Logic

Move the apply_patch and patch_files functions out of main.py and into patch.py. Make sure to add imports to main.py to be able to call the moved functions.

No output from pytest

The call to pytest isn't returning any error information on stderr when a pytest test throws an exception. Please update the command line arguments so it does.

More Git Work

Add a function to repo.py using Git-Python to commit local modifications to the current branch. Also, move fetch_open_issues to repo.py.

Publish PR from issue

Update the process issue function to use the functions in repo.py to:

  1. Switch to a branch "issue-", based on the id of the Issue that's passed in.
  2. Write the update
  3. Push the branch to remote
  4. Create a pull request with the Issue's title, if one doesn't exist.

Further Git Changes

  • Add a function to repo.py to check if an open pull request with a given title exists.
  • Refactor fetch_open_issues to return an Issue dataclass, which contains an id, title and description.

Test Issue #3

Please rename the main function to main2 and replace all occurences.

Move file updates

Move list_files, apply_prompt_to_files and check_result to transform.py

Refactor GPT Query

Refactor gpt_query to also take an optional system parameter. Move the current system prompt to a top level constant called SYSTEM_PATCH, and if no parameter is supplied to gpt_query, use SYSTEM_PATCH as the default.

Clean up dead code

Remove any instance of code which can't be executed under any circumstances.

Move GPT code to a new file

Move gpt_query to gpt.py, deleting it from main.py. Add imports to main.py to allow it to still be called, and whatever imports are required in gpt.py.

Add utils file

Move read_file and write_file to utils.py. Fix imports, then make sure moved code is deleted at the original location.

Test issue

Please rename the main function in src/main.py only to main2 and replace all occurances in that file.

Add test for partition_by_predicate

The function partition_by_predicate takes in a list, and returns a list of lists. The function loops over the input, adding each element to a list. Each time the predicate returns true, it starts on a new list with that element.

Every element of the input list is contained in the output lists.

For example, [1,2,3,4,5,6,8,10] with is_even would result in [[1],[2,3],[4,5],[6],[8],[10]].

Add some tests for partition_by_predicate that can be executed via pytest, and update its docstring to be a paragraph long to explain its use. Create at least five tests that exercise any edge cases you can imagine, but please keep them short.

Add retries flag

Add a flag -r or --retries which allows a configurable number of retries to be set in main.py. Default is 5.

More Git plumbing

Add a function that creates the specified branch using GitPython, switches to it, runs a specified callback to make changes to the filesystem, then commits and pushes the branch.

Change the main function to use this new function, creating a branch which is a hash of the prompt.

Fix check_result calls

In apply_prompt_to_files, there are two calls to check_result, one with all files, and one with filtered files.

Remove the check of all files.

Additionally, the filtering logic is incorrect.

A file should be kept in new_files if it has changed since old_files, OR if it's brand new.

A file should be kept in old_files if it has changed since new_files, OR if new_files has removed it.

Create Apply Prompt function

In main.py, create a function that takes a prompt string, and contains all of the logic to apply the prompt to a dictionary of files, containing filenames as keys and the contents of the files as values. Move this logic out of the loop over issues in the main function.

Don't check identical files

In apply_prompt_to_files, call check_result with modified old_files and new_files lists that remove unchanged key/value pairs from both lists.

Retry Issue Processing

Retry up to five times when calling process_issue in the main function. If it throws an exception, run it again.

Clean up pass

Make sure each function has a one line docstring, add type hints and format correctly.

Test Issue #2

Please rename the main function to main2 and replace all occurences.

Add commit title and body

  • Update the commit_local_modifications function in repo.py to take a commit name and body.
  • Update the process_issue function in main.py to pass in the Issue's name and Issue's body to commit_local_modifications

Call pytest after writing files

In process_issue, call pytest after writing the updated files. Do this by executing it in a shell.

If pytest fails, throw an exception.

Create process_issue function

Create a function in main.py to process issues, replacing the code in the loop in the main function. It should take an Issue as a parameter (make sure to import it).

Add formatting with Black

Add a function that takes Python in a string, and uses the Black package to format it, returning a string.

Add Git functions

Using GitPython, and PyGithub, create the following functions in a new repo.py:

  1. Pull from the origin, then switch to a branch id, creating it if necessary. Then reset the local branch to be equivalent to origin/main. The function should work exactly the same regardless of whether origin has the branch yet.
  2. Push the local branch created in this way to the same branch name on origin.
  3. Create a pull request for the specified repository name and branch id to main, with the specified title and body.

Move Add Line Numbers

Move the add_line_numbers from main.py to utils.py. Ensure to add an import if required to main.py to import the moved function. Also add any required imports to utils.py.

Move imports to the top

Move all input statements to the top of the file. They should never be placed after code or variable declarations.

Commit with Issue name and description

  • Update the commit_local_modifications function in repo.py to take a commit subject and body.
  • Update the process_issue function in main.py to pass in the Issue's name for the commit name, and the Issue's description for the commit body with the formatting 'Prompt: ""'

Add caching system

Add a cache.py file, which implements a key value store on the disk with read and write. Values should be stored in a .cache/ directory, using md5 hash of the keys. Reading a non existent key should throw an exception.

Add a function which can memoize function calls by storing their arguments to the KV store.

Make partition tests more succinct

The partition_by_predicate tests are good, but much too long. Make them neater, and use pytest features like parameterization if necessary.

Add Python file listing

Add a function that lists all of the Python files in the working directory, as well as subdirectories. The return value should be an array of relative paths as strings.

Add test to apply_prompt_to_files

Add a test for the main.py apply_prompt_to_files function in test_main.py. The prompt should be "create a function called add_test which adds one to the input", with an empty file for input. Take the resulting output code, and exec it, extracting the add_test function from the resulting environment. Test whether the add_test function works.

Print attempts in main.py

For each attempt in the loop in main.py, print "Attempt 1" etc in the console. Use the termcolor library in order to mark these in pink on the console.

When an exception happens in this loop, print the exception that was thrown in red.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.