Skip to content

Commit

Permalink
refactor logging
Browse files Browse the repository at this point in the history
  • Loading branch information
josephjclark committed May 9, 2024
1 parent a3aa8df commit 3092ccd
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 40 deletions.
4 changes: 2 additions & 2 deletions services/adaptor_gen/adaptor_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

from signature_generator import signature_generator as sig_gen
from code_generator import code_generator as code_gen
from util import createLogger

logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
logger = createLogger("adaptor_gen")


class Payload(DictObj):
Expand Down
10 changes: 4 additions & 6 deletions services/code_generator/code_generator.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import logging
from util import DictObj
from util import DictObj, createLogger

from .utils import (
generate_code_prompt,
Expand All @@ -8,8 +7,7 @@
from inference import inference


logging.basicConfig(level=logging.INFO, filename="out.txt")
logger = logging.getLogger(__name__)
logger = createLogger("code_generator")


class Payload(DictObj):
Expand All @@ -21,9 +19,9 @@ class Payload(DictObj):
# generate adaptor code based on a model and signature
def main(dataDict) -> str:
data = Payload(dataDict)

logger.generate("Running code generator with model {}".format(data.model))
result = generate(data.model, data.signature, data.get("api_key"))

logger.generate("Code generation complete!")
return result


Expand Down
5 changes: 2 additions & 3 deletions services/code_generator/prompts.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import copy
import logging
from util import createLogger

logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
logger = createLogger("code_generator.prompts")


prompts = {
Expand Down
5 changes: 4 additions & 1 deletion services/code_generator/utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import logging
import os
from .prompts import generate_prompt

from util import createLogger

logger = createLogger("code_generator.utils")

# Configure logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
Expand Down
5 changes: 3 additions & 2 deletions services/inference/models/codet5.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@

from transformers import RobertaTokenizer, T5ForConditionalGeneration

logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
from util import createLogger

logger = createLogger("inference.codet5")


"""
Expand Down
7 changes: 4 additions & 3 deletions services/inference/models/gpt3_turbo.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import logging
import os

from openai import OpenAI

logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
from util import createLogger

logger = createLogger("inference.gpt3_turbo")


OPENAI_API_KEY = os.getenv(
"OPENAI_API_KEY",
Expand Down
6 changes: 3 additions & 3 deletions services/inference/models/gpt_ft.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import logging
import os

from openai import OpenAI

logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
from util import createLogger

logger = createLogger("inference.gpt_ft")

OPENAI_API_KEY = os.getenv(
"OPENAI_API_KEY",
Expand Down
8 changes: 3 additions & 5 deletions services/signature_generator/signature_generator.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import logging

import inference.inference

from .prompts import generate_prompt
Expand All @@ -12,9 +10,9 @@

from inference import inference

# TODO the platform should deal with logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
from util import createLogger

logger = createLogger("signature_generator")


class Payload(DictObj):
Expand Down
7 changes: 3 additions & 4 deletions services/signature_generator/utils.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import logging
import os

import spacy
from spacy.tokens import Doc, Token

logger = logging.getLogger(__name__)
from util import createLogger

logger = createLogger("signature_generator.utils")

# Load the English language model
nlp = spacy.load("en_core_web_sm")
Expand Down
11 changes: 0 additions & 11 deletions services/slow/slow.py

This file was deleted.

0 comments on commit 3092ccd

Please sign in to comment.