Fix for init-actions

This commit is contained in:
renaud 2024-05-31 03:57:26 -07:00
parent 6957f36601
commit f8bd0f14f9
4 changed files with 22 additions and 15 deletions

View file

@ -5,7 +5,7 @@
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<option name="SDK_HOME" value="$USER_HOME$/mambaforge/envs/codeflash311/bin/python" />
<option name="WORKING_DIRECTORY" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/cli" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />

View file

@ -1,5 +1,5 @@
from __future__ import annotations
from sqlalchemy import Boolean, Column, ForeignKey, Integer, Text
from sqlalchemy.orm import Session, relationship
from time import time
from sqlalchemy import Boolean, Column, ForeignKey, Integer, Text
@ -47,7 +47,6 @@ def init_table() -> Session:
return session
def get_authors(session: Session) -> list[Author]:
books: list[Book] = session.query(Book).all()
_authors: list[Author] = []
@ -59,6 +58,19 @@ def get_authors(session: Session) -> list[Author]:
key=lambda x: x.id,
)
def get_authors2(num_authors) -> list[Author]:
engine: Engine = create_engine(POSTGRES_CONNECTION_STRING, echo=True)
session_factory: sessionmaker[Session] = sessionmaker(bind=engine)
session: Session = session_factory()
books: list[Book] = session.query(Book).all()
_authors: list[Author] = []
book: Book
for book in books:
_authors.append(book.author)
return sorted(
list(set(_authors)),
key=lambda x: x.id,
)[:num_authors]
if __name__ == "__main__":
engine: Engine = create_engine(POSTGRES_CONNECTION_STRING, echo=True)

View file

@ -1,5 +1,4 @@
import ast
import logging
import os
import re
import subprocess
@ -125,7 +124,7 @@ def collect_setup_info() -> SetupInfo:
if not d.startswith(".") and not d.startswith("__") and d not in ignore_subdirs
]
valid_module_subdirs = [dir for dir in valid_subdirs if dir != "tests"]
valid_module_subdirs = [d for d in valid_subdirs if d != "tests"]
curdir_option = "current directory (" + curdir + ")"
module_subdir_options = valid_module_subdirs + [curdir_option]
@ -349,15 +348,11 @@ def install_github_actions() -> None:
ph("cli-github-workflow-skipped")
apologize_and_exit()
os.makedirs(workflows_path, exist_ok=True)
from importlib.resources import read_text
from importlib.resources import files
py_version = sys.version_info
python_version_string = f" {py_version.major}.{py_version.minor}"
optimize_yml_content = read_text(
"codeflash.cli_cmds.workflows",
"codeflash-optimize.yaml",
)
optimize_yml_content = files("codeflash").joinpath(
"cli_cmds", "workflows", "codeflash-optimize.yaml").read_text(encoding='utf-8')
optimize_yml_content = optimize_yml_content.replace(
" {{ python_version }}",
python_version_string,

View file

@ -1,3 +1,3 @@
# These version placeholders will be replaced by poetry-dynamic-versioning during `poetry build`.
__version__ = "0.6.4"
__version_tuple__ = (0, 6, 4)
__version__ = "0.6.4.post32.dev0+6957f366"
__version_tuple__ = (0, 6, 4, "post32", "dev0", "6957f366")