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

autoconfig overwrites doesnt support layers ? #613

Open
landryb opened this issue Dec 15, 2022 · 2 comments
Open

autoconfig overwrites doesnt support layers ? #613

landryb opened this issue Dec 15, 2022 · 2 comments
Labels

Comments

@landryb
Copy link

landryb commented Dec 15, 2022

Context

I'm trying to use mapproxy-util autoconfig with an overwrite file containing a layers section:

layers:
    __all__:
      md:
        attribution:
          url: https://foo.bar

Expected Behavior

a valid config should be generated, adding the md/attribution/url section to all layers.

Actual Behavior

python traceback, because layers is a list and not a dict ?

 $mapproxy-util autoconfig --capabilities https://foo.bar/ortho --output=/tmp/ortho3.yaml --overwrite generated/overwrite_ortho.yaml --base=common/base.yaml --force
[2022-12-14 15:55:07,512] mapproxy.config - WARNING - Missing layers section
Traceback (most recent call last):
  File "/usr/bin/mapproxy-util", line 33, in <module>
    sys.exit(load_entry_point('MapProxy==1.13.0', 'console_scripts', 'mapproxy-util')())
  File "/usr/lib/python3/dist-packages/mapproxy/script/util.py", line 387, in main
    commands[command]['func'](args)
  File "/usr/lib/python3/dist-packages/mapproxy/script/conf/app.py", line 171, in config_command
    conf['layers'] = update_config(conf['layers'], overwrite.pop('layers', {}))
  File "/usr/lib/python3/dist-packages/mapproxy/script/conf/utils.py", line 49, in update_config
    for conf_k, conf_v in iteritems(conf):
  File "/usr/lib/python3/dist-packages/mapproxy/compat/__init__.py", line 27, in iteritems
    return d.items()
AttributeError: 'list' object has no attribute 'items'

I've also tried to use a list with:

layers:
  - __all__:

but that didn't help.

Possible Fix

add to the documentation how to properly overload config for layers like cache and sources, which are working fine ?
Fix the code so that it supports overwriting layers ? add a corresponding test ?

Steps to Reproduce

  1. using master, modify mapproxy/test/system/fixture/util-conf-overwrite.yaml to add a layers section:
+layers:
+    __all__:
+      md:
+        attribution:
+          url: https://foo.bar
 caches:
  1. run pytest on this test only
pytest-3 -v mapproxy/test/system/test_util_conf.py
  1. get a failing test:
mapproxy/test/system/test_util_conf.py::TestMapProxyConfCmd::test_overwrites FAILED                                                                                                                                                                                        [100%]

==================================================================================================================================== FAILURES ====================================================================================================================================
______________________________________________________________________________________________________________________ TestMapProxyConfCmd.test_overwrites _______________________________________________________________________________________________________________________

self = <mapproxy.test.system.test_util_conf.TestMapProxyConfCmd object at 0x7fd6273dff70>

    def test_overwrites(self):
        with capture(bytes=True) as (stdout, stderr):
>           assert (
                config_command(
                    [   
                        "mapproxy-conf",
                        "--capabilities",
                        filename("util-conf-wms-111-cap.xml"),
                        "--output",
                        self.tmp_filename("mapproxy.yaml"),
                        "--overwrite",
                        filename("util-conf-overwrite.yaml"),
                        "--base",
                        filename("util-conf-base-grids.yaml"),
                    ]
                )
                == 0
            )

mapproxy/test/system/test_util_conf.py:211:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
mapproxy/script/conf/app.py:174: in config_command
    conf['layers'] = update_config(conf['layers'], overwrite.pop('layers', {}))
mapproxy/script/conf/utils.py:49: in update_config
    for conf_k, conf_v in iteritems(conf):
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

d = [{'layers': [{'name': 'osm', 'sources': ['osm_cache'], 'title': 'OpenStreetMap (complete map)'}, {'name': 'osm_roads', 'sources': ['osm_roads_cache'], 'title': 'OpenStreetMap (streets only)'}], 'title': 'Omniscale OpenStreetMap WMS'}]

    def iteritems(d):
>       return d.items()
E       AttributeError: 'list' object has no attribute 'items'

mapproxy/compat/__init__.py:27: AttributeError
------------------------------------------------------------------------------------------------------------------------------ Captured stdout call ------------------------------------------------------------------------------------------------------------------------------
'list' object has no attribute 'items'
------------------------------------------------------------------------------------------------------------------------------- Captured log call --------------------------------------------------------------------------------------------------------------------------------
WARNING  mapproxy.config:loader.py:2182 Missing layers section
WARNING  mapproxy.config:loader.py:2182 Missing services section

Context

Your Environment

  • Version used: 1.13.0 on production, but reproduced with master
  • Environment name and version (e.g. Python 2.7.5 with mod_wsgi 4.5.9): python 3.7
  • Server type and version: gunicorn
  • Operating System and version: debian 11
@weskamm
Copy link
Member

weskamm commented Jan 12, 2023

Thanks for the report, maybe you can come up with a PR which fixes this as you suggested?

@weskamm
Copy link
Member

weskamm commented Jan 12, 2023

maybe related to #576

@weskamm weskamm added the bug label Jan 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants