-
Notifications
You must be signed in to change notification settings - Fork 1
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
Feature/address on local #256
Conversation
Having some difficulty getting going on Windows 10 - is this expected to work for all current Python versions? Could be my environment / use of conda / having installed many previous versions. |
@RyanJField currently getting (win 10, py 3.9):
using |
Registry install ( |
The differences between Should I install the registry via FAIR-CLI from PyPI and then reinstall FAIR-CLI from this branch to review this PR, or is it best to address the install issue with |
The version on PyPi for windows should use the main branch of the registry, however the version on GitHub uses the latest tagged release (unless otherwise specified) which is currently broken for windows 10 python 3.10, this PR fixed it FAIRDataPipeline/data-registry@971cde5 but I need to push a new tagged release and I'm waiting for this PR to be approved first: FAIRDataPipeline/data-registry#191 so that there is only one release (and not two). Hope this makes sense. Once the push functionality is working and the CLI is better tested we should update the PyPi release. The GitHub version of the registry requires extra steps (specifying the remote registry or using the local flag) than the PyPi version so we were waiting for the paper to be accepted to update it (incase any of the reviewers wanted to run the code). |
Cheers - I'll look at FAIRDataPipeline/data-registry#191 first, then. |
Should I wait for #257 to be merged before looking at this again, or install off |
Or is this (#256) now the blocker? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These changes look good, in themselves. I don't know Django or a huge amount about big design decisions made earlier on in this repo's history so can't properly review in context.
@@ -324,14 +324,16 @@ def install(debug: bool, force: bool, directory: str, version: str): | |||
@registry.command() | |||
@click.option("--debug/--no-debug", help="Run in debug mode", default=False) | |||
@click.option("--port", help="port on which to run registry", default=8000) | |||
def start(debug: bool, port: int) -> None: | |||
@click.option("--address", help="Address on which to run registry", default="127.0.0.1") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this option is working, but I can only get the registry to start on 127.0.0.1
.
@@ -324,14 +324,16 @@ def install(debug: bool, force: bool, directory: str, version: str): | |||
@registry.command() | |||
@click.option("--debug/--no-debug", help="Run in debug mode", default=False) | |||
@click.option("--port", help="port on which to run registry", default=8000) | |||
def start(debug: bool, port: int) -> None: | |||
@click.option("--address", help="Address on which to run registry", default="127.0.0.1") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Win 10, Py 10
Works with --address 127.0.0.1
not with 192.168.1.101
my laptop address at the time - gives Bad Request (400)
so serving something! The bit, the click CLI is clearly OK.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an issue with allowed hosts: base_settings.py
The address will need adding to the allowed hosts or allowing all hosts.
ALLOWED_HOSTS = ['*']
ALLOWED_HOSTS = ['127.0.0.1', 'localhost', '192.168.0.101']
This can be added to local-settings.py
Or we could import local settings into a new settings file and put it there.
Open to suggestions on where and how we add this in?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi sorry if I jump in.
I would not allow any hosts.
I would edit the Django settings to be like
ALLOWED_HOSTS = []
ALLOWED_HOSTS.extend(
filter(None, os.environ.get("ALLOWED_HOSTS", "").split(","))
)
And then pass allowed host as env variable.
This would allow to have less maintenance overhead in the Django app for future changes.
You could also create a sys-env variable (prod/testing/staging) and have different Django settings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My intuition here is that this feature is going to be used infrequently or by expert users for either running in containers or deploying a "remote" registry. @bruvio's suggestion looks good (with my limited Django). Thanks! I agree that allowing all hosts by default is unlikely to be good practise.
I think if you go with the suggestion, it should be documented somewhere. I guess the other way might be to just document what manual changes are needed to these files to allow the host specified by the CLI.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi sorry if I jump in.
I would not allow any hosts.
I would edit the Django settings to be like
ALLOWED_HOSTS = [] ALLOWED_HOSTS.extend( filter(None, os.environ.get("ALLOWED_HOSTS", "").split(",")) )
And then pass allowed host as env variable.
This would allow to have less maintenance overhead in the Django app for future changes.
You could also create a sys-env variable (prod/testing/staging) and have different Django settings.
Thanks @bruvio
Agree this is a good solution, I would probably set allowed hosts in the settings to ['127.0.0.1', 'localhost'] prior to extending it with the environment variable so if the environmental variable is not set, it will still run on both.
I'll put in a PR on the registry and we can add the address to the environment variable in the start registry function
current/most recent address used to launch the registry | ||
""" | ||
if not os.path.exists(registry_session_address_file(registry_dir)): | ||
_logger.warning("Session Address file not found, please make sure your registry is up-to-date") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this could happen with an older registry version running.
with tempfile.TemporaryDirectory() as tempd: | ||
reg_dir = os.path.join(tempd, "registry") | ||
mocker.patch("fair.common.DEFAULT_REGISTRY_LOCATION", reg_dir) | ||
fdp_serv.install_registry(install_dir=reg_dir) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe there's a fixture that could be used in situations like this to avoid multiple installs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a registry fixture but it cannot be used for these commands due to an issue with the virtual environment it uses. To rewrite it would take time.
Co-authored-by: bobturneruk <34244196+bobturneruk@users.noreply.github.com>
Codecov Report
@@ Coverage Diff @@
## develop #256 +/- ##
===========================================
+ Coverage 69.38% 69.55% +0.17%
===========================================
Files 27 27
Lines 3642 3653 +11
===========================================
+ Hits 2527 2541 +14
+ Misses 1115 1112 -3
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
Implemented address parameter to allow the local registry to be bound to an alternative address (interface).
Fixed check_grid as the grid api has been moved over to ROR