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

Add option to specify port #192

Merged
merged 1 commit into from Dec 31, 2022
Merged

Add option to specify port #192

merged 1 commit into from Dec 31, 2022

Conversation

pysqz
Copy link
Contributor

@pysqz pysqz commented Dec 30, 2022

fix issue #157

@pysqz pysqz mentioned this pull request Dec 30, 2022
@Alek99 Alek99 self-requested a review December 30, 2022 07:51
Copy link
Contributor

@picklelo picklelo 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 making this change!

@@ -533,6 +537,13 @@ def get_num_workers() -> int:
return (os.cpu_count() or 1) * 2 + 1


def get_api_port():
Copy link
Contributor

@picklelo picklelo Dec 30, 2022

Choose a reason for hiding this comment

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

This needs a return type annotation -> int as well as a docstring to make the build happy.
The docstring can just be

"""Get the API port.

Returns:
    The API port.
"""

def get_api_port():
result = urlparse(get_config().api_url)
if result.port is None:
return urlparse(constants.API_URL).port
Copy link
Contributor

Choose a reason for hiding this comment

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

You may need to add an assert here for Pyright

port = urlparse(...)
assert port is not None
return port

@@ -559,6 +571,8 @@ def run_backend_prod(
"""
num_workers = get_num_workers()
command = constants.RUN_BACKEND_PROD + [
"--bind",
"0.0.0.0:%s"%get_api_port(),
Copy link
Contributor

@picklelo picklelo Dec 30, 2022

Choose a reason for hiding this comment

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

Can we use an f-string here for consistency with the rest of the code?

f"0.0.0.0:{get_api_port()}"

@Alek99
Copy link
Contributor

Alek99 commented Dec 30, 2022

Yes thanks for implementing this feature definitely needed! 🙂

@pysqz
Copy link
Contributor Author

pysqz commented Dec 30, 2022

update the commit, pls review again~ @picklelo @Alek99

@pysqz pysqz requested review from picklelo and removed request for Alek99 December 30, 2022 09:05
Copy link
Contributor

@picklelo picklelo left a comment

Choose a reason for hiding this comment

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

Looks good to me - it just needs to be linted. You can run

poetry run black pynecone

and it should format the code for you, then we can merge this

@picklelo picklelo linked an issue Dec 30, 2022 that may be closed by this pull request
@pysqz
Copy link
Contributor Author

pysqz commented Dec 31, 2022

Looks good to me - it just needs to be linted. You can run

poetry run black pynecone

and it should format the code for you, then we can merge this

Done. @picklelo

@picklelo picklelo merged commit 22deb9e into reflex-dev:main Dec 31, 2022
ACucos1 pushed a commit to ACucos1/rd-pynecone that referenced this pull request Feb 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add option to specify port
3 participants