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

Service URL key checking and enhance xml parsing performance for WMS layers #103

Merged
merged 4 commits into from
Jul 9, 2018

Conversation

barryytm
Copy link
Collaborator

@barryytm barryytm commented Jul 9, 2018

Relates to #99

Check if there were existing keys in the wms service url and enhance xml parsing performance for WMS layers.

Note: It is for python 2.7.


This change is Reviewable

@barryytm
Copy link
Collaborator Author

barryytm commented Jul 9, 2018

Close this to fix the style problem as my local machine didn't flag me the error. Will reopen again.

@barryytm barryytm closed this Jul 9, 2018
@barryytm barryytm reopened this Jul 9, 2018
Copy link
Contributor

@alyec alyec left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 1 files at r2.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @barryytm, @dan-bowerman, and @james-rae)


services/regparse/ogc.py, line 2 at r2 (raw file):

import requests
import xml.etree.ElementTree as ETree

How does etree enhance parsing with respect to minidom?


services/regparse/ogc.py, line 59 at r2 (raw file):

def str2bool(v):

str2bool looks like a single use utility function; if it isn't needed anymore it should be removed (but please ensure the output of layer.attrib is a boolean type before doing so)

Copy link
Collaborator Author

@barryytm barryytm left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 1 files reviewed, 2 unresolved discussions (waiting on @alyec, @barryytm, @dan-bowerman, and @james-rae)


services/regparse/ogc.py, line 2 at r2 (raw file):

Previously, alyec (Aly Merchant) wrote…

How does etree enhance parsing with respect to minidom?

Tried http://geo.weather.gc.ca/geomet/?lang=E&SERVICE=WMS&REQUEST=GetCapabilities on minidom and it was timed out. https://wiki.python.org/moin/MiniDom suggested to use elementTree and it worked.

Here is a JSON snippet for testing:

{
    "fr": {
        "feature_info_format": "text/plain",
        "service_url": "http://geo.weather.gc.ca/geomet/?lang=F",
        "service_type": "ogcWms",
        "legend_format": "image/png",
        "scrape_only": [
            "HRDPS.CONTINENTAL_NT"
        ],
        "service_name": "HRDPS.CONTINENTAL - Total cloud cover (fraction)"
    },
    "en": {
        "feature_info_format": "text/plain",
        "service_url": "http://geo.weather.gc.ca/geomet/?lang=E",
        "service_type": "ogcWms",
        "legend_format": "image/png",
        "scrape_only": [
            "HRDPS.CONTINENTAL_NT"
        ],
        "service_name": "HRDPS.CONTINENTAL - Total cloud cover (fraction)"
    },
    "version": "2.0"
}

services/regparse/ogc.py, line 59 at r2 (raw file):

Previously, alyec (Aly Merchant) wrote…

str2bool looks like a single use utility function; if it isn't needed anymore it should be removed (but please ensure the output of layer.attrib is a boolean type before doing so)

Sorry, forgot to put that back. Done, thanks

@barryytm
Copy link
Collaborator Author

barryytm commented Jul 9, 2018

This comment is for heartbeat as my reply in reviewable didn't trigger it.

Copy link
Contributor

@alyec alyec left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 1 files reviewed, 1 unresolved discussion (waiting on @alyec, @barryytm, @dan-bowerman, and @james-rae)


services/regparse/ogc.py, line 79 at r3 (raw file):

            id = id.text
            title = layer.find(namespace + 'Title').text
            queryable = str2bool((layer.attrib)['queryable'])

I believe queryable is optional. Have you tested the str2bool version with a capabilities file that has queryable missing on some nodes?

Copy link
Contributor

@alyec alyec left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 1 files at r3.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @barryytm, @dan-bowerman, and @james-rae)

Copy link
Member

@dan-bowerman dan-bowerman left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 1 files at r3.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @barryytm and @james-rae)

Copy link
Collaborator Author

@barryytm barryytm left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 1 files reviewed, 1 unresolved discussion (waiting on @alyec, @dan-bowerman, @barryytm, and @james-rae)


services/regparse/ogc.py, line 79 at r3 (raw file):

Previously, alyec (Aly Merchant) wrote…

I believe queryable is optional. Have you tested the str2bool version with a capabilities file that has queryable missing on some nodes?

I've changed it to use get() instead, and it returns None if not found. I have also made str2bool return False if the value is None. Therefore if queryable is missing, str2bool will return False. Thanks.

@barryytm
Copy link
Collaborator Author

barryytm commented Jul 9, 2018

This comment is to trigger heartbeat.

Copy link
Contributor

@alyec alyec left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 1 files at r4.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @james-rae)

@dan-bowerman dan-bowerman merged commit 79b614d into fgpv-vpgf:python-2.7 Jul 9, 2018
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.

4 participants