Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP]Feature, configurable network port #6678

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

lukolszewski
Copy link

Background

This implements a configurable network port. I often have other stuff running locally on port 8000 and I wanted to be able to change this default.

Changes πŸ—οΈ

This only adds a config option named serving_port which reads the environment variable PORT, if this is not present it defaults to 8000.

PR Quality Scorecard ✨

  • Have you used the PR description template?   +2 pts
  • Is your pull request atomic, focusing on a single change?   +5 pts
  • Have you linked the GitHub issue(s) that this PR addresses?   +5 pts
  • Have you documented your changes clearly and comprehensively?   +5 pts
  • Have you changed or added a feature?   -4 pts
  • Have you added/updated corresponding documentation?   +4 pts
  • Have you added/updated corresponding integration tests?   +5 pts
  • Have you changed the behavior of AutoGPT?   -5 pts
  • Have you also run agbenchmark to verify that these changes do not regress performance?   +10 pts

Copy link

netlify bot commented Jan 6, 2024

βœ… Deploy Preview for auto-gpt-docs ready!

Name Link
πŸ”¨ Latest commit 87ab221
πŸ” Latest deploy log https://app.netlify.com/sites/auto-gpt-docs/deploys/659abd0a3aea2f00080bcd68
😎 Deploy Preview https://deploy-preview-6678--auto-gpt-docs.netlify.app
πŸ“± Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@lukolszewski lukolszewski changed the title Feature, configurable network port [WIP]Feature, configurable network port Jan 7, 2024
@github-actions github-actions bot added size/m and removed size/s labels Jan 7, 2024
Copy link
Member

@Pwuts Pwuts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the useful proposal! Please check out the comments below:

try:
pids = subprocess.check_output(["lsof", "-t", "-i", ":8000"]).split()
pids = subprocess.check_output(["lsof", "-t", "-i", ":"+str(agent_port)]).split()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
pids = subprocess.check_output(["lsof", "-t", "-i", ":"+str(agent_port)]).split()
pids = subprocess.check_output(["lsof", "-t", "-i", f":{agent_port}"]).split()

@@ -314,7 +317,7 @@ def stop():
click.echo("No process is running on port 8000")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
click.echo("No process is running on port 8000")
click.echo(f"No process is running on port {agent_port}")

Comment on lines +118 to +121
agent_port: int = UserConfigurable(
default=8000,
from_env=lambda: int(v) if (v := os.getenv("AGENT_PORT")) else None,
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be in the "Application Settings" section, e.g. on line 55. Also, can you rename agent_port to serve_port or agent_serve_port?

kill $(lsof -t -i :8000)
kill $(lsof -t -i :${AGENT_PORT:-8080})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. This should default to 8000 like it does now
  2. This will break the benchmark when AGENT_PORT is not set to its default, because AGBenchmark uses the host property (including port) from agbenchmark_config/config.json to connect to the subject agent's API.

run
set -a
source .env
set +a
python3 cli.py "$@"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing \n

run

python3 cli.py "$@"
set -a
source .env
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For most users, .env does not exist and this shows a warning.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AGBenchmark reads PORT, not BENCHMARK_PORT:

# Run the FastAPI application using uvicorn
port = port or int(os.getenv("PORT", 8080))
uvicorn.run(app, host="0.0.0.0", port=port)

@@ -368,7 +368,7 @@ async def run_auto_gpt_server(
server = AgentProtocolServer(
app_config=config, database=database, llm_provider=llm_provider
)
await server.start()
await server.start(port=config.serving_port)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does not match the config attribute created in config.py

@Pwuts
Copy link
Member

Pwuts commented Jan 12, 2024

Just merged #6569 which makes the port configurable but doesn't touch the run and run_benchmark scripts etc. If you address the comments and resolve the conflict this can still be merged.

Copy link

This pull request has conflicts with the base branch, please resolve those so we can evaluate the pull request.

@github-actions github-actions bot added the conflicts Automatically applied to PRs with merge conflicts label Jan 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: 🚧 Needs work
Development

Successfully merging this pull request may close these issues.

None yet

2 participants