Skip to content

Commit

Permalink
Merge pull request #364 from Gregory-Pereira/enable-env-in-container-…
Browse files Browse the repository at this point in the history
…builds

GITHUB_TOKEN and GITHUB_USER passable via env worker + bot
  • Loading branch information
mergify[bot] authored May 20, 2024
2 parents 3e75fff + 64d0b97 commit 26dd4da
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 2 deletions.
9 changes: 9 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -221,3 +221,12 @@ run-on-kind:
$(CMD_PREFIX) kubectl create namespace instructlab-bot
$(CMD_PREFIX) kubectl create -n instructlab-bot secret generic instructlab-bot --from-env-file=.env
$(CMD_PREFIX) kubectl apply -k deploy/instructlab-bot/overlays/dev

.PHONY: docker-clean
docker-clean:
@container_ids=$$(podman ps -a --format "{{.ID}}" | awk '{print $$1}'); \
echo "removing all stopped containers (non-force)"; \
for id in $$container_ids; do \
echo "Removing container: $$id,"; \
podman rm $$id; \
done
6 changes: 6 additions & 0 deletions gobot/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ func init() {
rootCmd.PersistentFlags().StringSliceVarP(&Maintainers, "maintainers", "", []string{}, "GitHub users or groups that are considered maintainers")
rootCmd.PersistentFlags().BoolVarP(&Debug, "debug", "d", false, "Enable debug logging")
rootCmd.PersistentFlags().StringVarP(&BotUsername, "bot-username", "", "@instructlab-bot", "The username of the bot")
if GithubToken == "" {
GithubToken = os.Getenv("ILWORKER_GITHUB_TOKEN")
}
if GithubUsername == "" {
GithubUsername = os.Getenv("ILWORKER_GITHUB_USERNAME")
}
}

var rootCmd = &cobra.Command{
Expand Down
2 changes: 1 addition & 1 deletion worker/Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ENV WORK_DIR /app

WORKDIR ${WORK_DIR}

COPY . ${WORK_DIR}/instructlab-bot
COPY worker ${WORK_DIR}/instructlab-bot/worker

# Build the worker binary
WORKDIR ${WORK_DIR}/instructlab-bot/worker
Expand Down
16 changes: 15 additions & 1 deletion worker/cmd/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ type IlabConfig struct {
func init() {
generateCmd.Flags().StringVarP(&WorkDir, "work-dir", "w", "", "Directory to work in")
generateCmd.Flags().StringVarP(&VenvDir, "venv-dir", "v", "", "The virtual environment directory")
generateCmd.Flags().StringVarP(&PreCheckEndpointURL, "precheck-endpoint-url", "e", "http://localhost:8000/v1", "Endpoint hosting the model API. Default, it assumes the model is served locally.")
generateCmd.Flags().StringVarP(&PreCheckEndpointURL, "precheck-endpoint-url", "e", "", "Endpoint hosting the model API. Default, it assumes the model is served locally.")
generateCmd.Flags().StringVarP(&SdgEndpointURL, "sdg-endpoint-url", "", "http://localhost:8000/v1", "Endpoint hosting the model API. Default, it assumes the model is served locally.")
generateCmd.Flags().IntVarP(&NumInstructions, "num-instructions", "n", 10, "The number of instructions to generate")
generateCmd.Flags().StringVarP(&GitRemote, "git-remote", "", "https://github.com/instructlab/taxonomy", "The git remote for the taxonomy repo")
Expand All @@ -131,6 +131,20 @@ func init() {
generateCmd.Flags().StringVarP(&TlsServerCaCertPath, "tls-server-ca-cert", "", "server-ca-crt.pem2", "Path to the TLS server CA certificate. Defaults to 'server-ca-crt.pem2'")
generateCmd.Flags().BoolVarP(&TlsInsecure, "tls-insecure", "", false, "Whether to skip TLS verification")
generateCmd.Flags().IntVarP(&MaxSeed, "max-seed", "m", 40, "Maximum number of seed Q&A pairs to process to SDG.")
if GithubToken == "" {
GithubToken = os.Getenv("ILWORKER_GITHUB_TOKEN")
}
if GithubUsername == "" {
GithubUsername = os.Getenv("ILWORKER_GITHUB_USERNAME")
}
if PreCheckEndpointURL == "" {
preCheckEndpointURLEnvValue := os.Getenv("PECHECK_ENDPOINT")
if preCheckEndpointURLEnvValue != "" {
PreCheckEndpointURL = preCheckEndpointURLEnvValue
} else {
PreCheckEndpointURL = localEndpoint
}
}
_ = generateCmd.MarkFlagRequired("github-token")
rootCmd.AddCommand(generateCmd)
}
Expand Down

0 comments on commit 26dd4da

Please sign in to comment.