internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: nextcloud/appstore

Issue:
Continuation from #414: comment defaults
On initial page load the comment language does not default to English if no comments are present in the user's language


Discussion:

Resolving patch:
diff --git a/nextcloudappstore/core/views.py b/nextcloudappstore/core/views.py
--- a/nextcloudappstore/core/views.py
+++ b/nextcloudappstore/core/views.py
@@ -74,7 +74,7 @@ def get_context_data(self, **kwargs):
             lambda r: r.get_available_languages(), ratings)
 
         # make sure current session language is in the list even if there are
-        # no comments
+        # no comments.
         rating_languages = list(rating_languages)
         if get_language() not in rating_languages:
             rating_languages.append(get_language())
@@ -85,6 +85,18 @@ def get_context_data(self, **kwargs):
             try:
                 app_rating = AppRating.objects.get(user=self.request.user,
                                                    app=context['app'])
+
+                # if parler fallsback to a fallback language
+                # it doesn't set the language as current language
+                # and we can't select the correct language in the
+                # frontend. So we try and find a languge that is
+                # available
+                language_code = app_rating.get_current_language()
+                if not app_rating.has_translation(language_code):
+                    for fallback in app_rating.get_fallback_languages():
+                        if app_rating.has_translation(fallback):
+                            app_rating.set_current_language(fallback)
+
                 # when accessing an empty comment django-parler tries to
                 # fall back to the default language. However for comments
                 # the default (English) does not always exist. Unfortunately


Test patch:
Repository: nextcloud/appstore

Issue:
App Generator creates faulty info.xml when using umlauts (special characters äöü)
Problem: nextcloud/apps/foo/appinfo/info.xml misses the closing **</info>** tag. Just generates **</**

## Details

* Browser and browser version: Firefox 55.0.3

## Steps to reproduce

Steps to reproduce:

- visit https://apps.nextcloud.com/developer/apps/generate
- enter the required information; in summary and description enter "This is a test app äöü"
- click generate and download.
- look at the generated info.xml


App Generator creates faulty info.xml when using umlauts (special characters äöü)
Problem: nextcloud/apps/foo/appinfo/info.xml misses the closing **</info>** tag. Just generates **</**

## Details

* Browser and browser version: Firefox 55.0.3

## Steps to reproduce

Steps to reproduce:

- visit https://apps.nextcloud.com/developer/apps/generate
- enter the required information; in summary and description enter "This is a test app äöü"
- click generate and download.
- look at the generated info.xml




Discussion:

Resolving patch:
diff --git a/nextcloudappstore/scaffolding/archive.py b/nextcloudappstore/scaffolding/archive.py
--- a/nextcloudappstore/scaffolding/archive.py
+++ b/nextcloudappstore/scaffolding/archive.py
@@ -1,9 +1,9 @@
 import re
 import tarfile
-from io import BytesIO, StringIO
-from typing import Dict
-from os.path import join, isdir, relpath
+from io import BytesIO
 from os import walk
+from os.path import join, isdir, relpath
+from typing import Dict
 
 from django.template import Context
 from django.template import Template
@@ -53,7 +53,8 @@ def build_archive(parameters: Dict[str, str]) -> BytesIO:
         files = build_files(parameters)
         for path, contents in files.items():
             info = tarfile.TarInfo(path)
-            info.size = len(contents)
-            f.addfile(info, BytesIO(contents.encode()))
+            encoded_content = contents.encode()
+            info.size = len(encoded_content)
+            f.addfile(info, BytesIO(encoded_content))
     buffer.seek(0)
     return buffer


Test patch:
Repository: nextcloud/appstore

Issue:
Verify email addresses after E-Mail change
When a user changes their email address, it should be verified. allauth provides some views for that which may or may not be useful. Unsure whether email addresses currently are verified at signup, but it would be appropriate for it to use the same mechanism.



Discussion:
This is definitely a big problem, since I changed my email address, I could not login  !
regards, hitam4450

@hitam4450 you log in with your user name ;D

Thank you for reminding me......but still fails, since the system keeps sending "stupidly" a confirmation email to my obsolete and non-existing email!

regards, hitam4450

Got the same problem sometime when I change the e-mail address. I cannot log in with the old and with the new one. Can be a little bit annoying. 

Resolving patch:
diff --git a/nextcloudappstore/user/views.py b/nextcloudappstore/user/views.py
--- a/nextcloudappstore/user/views.py
+++ b/nextcloudappstore/user/views.py
@@ -70,8 +70,7 @@ def get_context_data(self, **kwargs):
 
     def form_valid(self, form):
         email = EmailAddress.objects.get_primary(user=self.request.user)
-        email.email = form.cleaned_data['email']
-        email.save()
+        email.change(None, form.cleaned_data['email'])
         messages.success(self.request, 'Account details saved.')
         return super().form_valid(form)
 


Test patch:
Repository: nextcloud/appstore

Issue:
add "Featured" category
In order to find "Featured" labeled apps better, there should be a separate category, making all official apps accessible on one screen.


Discussion:
comment by @juliushaertl from https://github.com/nextcloud/appstore/pull/649#issuecomment-580254869:

> It is available as `isFeatured` in the response of the app store api so we should be able to just create a new list and filter for those in the server.

Resolving patch:
diff --git a/nextcloudappstore/core/views.py b/nextcloudappstore/core/views.py
--- a/nextcloudappstore/core/views.py
+++ b/nextcloudappstore/core/views.py
@@ -174,7 +174,8 @@ class CategoryAppListView(ListView):
     def get_queryset(self):
         order_by = self.request.GET.get('order_by', 'rating_overall')
         ordering = self.request.GET.get('ordering', 'desc')
-        is_featured = self.request.GET.get('is_featured', False)
+        is_featured = self.request.GET.get('is_featured', self.kwargs
+                                           .get('is_featured_category', False))
         maintainer = self.request.GET.get('maintainer', False)
         sort_columns = []
 
@@ -210,6 +211,8 @@ def get_context_data(self, **kwargs):
         context['categories'] = Category.objects.prefetch_related(
             'translations').all()
         category_id = self.kwargs['id']
+        context['is_featured_category'] = self.kwargs\
+            .get('is_featured_category', False)
         if category_id:
             context['current_category'] = Category.objects.get(id=category_id)
         if self.search_terms:
diff --git a/nextcloudappstore/urls.py b/nextcloudappstore/urls.py
--- a/nextcloudappstore/urls.py
+++ b/nextcloudappstore/urls.py
@@ -19,6 +19,10 @@
 
 urlpatterns = [
     url(r'^$', CategoryAppListView.as_view(), {'id': None}, name='home'),
+    url(r"^featured$", CategoryAppListView.as_view(), {'id': None,
+                                                       'is_featured_category':
+                                                           True},
+        name='featured'),
     url(r"^signup/$", csp_update(**settings.CSP_SIGNUP)(signup),
         name="account_signup"),
     url(r"^social/signup/$", csp_update(**settings.CSP_SIGNUP)(social_signup),


Test patch:
Repository: nextcloud/appstore

Issue:
HTTP 500 instead of 404 on unknown category
* open https://apps.nextcloud.com/category/auth
* actual: get a 500 and a log entry
* expected: get a 404

Log line:

```
Internal Server Error: /categories/auth
Traceback (most recent call last):
  File "/opt/appstore/venv/lib/python3.5/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/opt/appstore/venv/lib/python3.5/site-packages/django/core/handlers/base.py", line 115, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/opt/appstore/venv/lib/python3.5/site-packages/django/core/handlers/base.py", line 113, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/opt/appstore/venv/lib/python3.5/site-packages/django/views/generic/base.py", line 71, in view
    return self.dispatch(request, *args, **kwargs)
  File "/opt/appstore/venv/lib/python3.5/site-packages/django/views/generic/base.py", line 97, in dispatch
    return handler(request, *args, **kwargs)
  File "/opt/appstore/venv/lib/python3.5/site-packages/django/views/generic/list.py", line 157, in get
    context = self.get_context_data()
  File "/opt/appstore/nextcloudappstore/core/views.py", line 222, in get_context_data
    context['current_category'] = Category.objects.get(id=category_id)
  File "/opt/appstore/venv/lib/python3.5/site-packages/django/db/models/manager.py", line 82, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/opt/appstore/venv/lib/python3.5/site-packages/django/db/models/query.py", line 408, in get
    self.model._meta.object_name
nextcloudappstore.core.models.Category.DoesNotExist: Category matching query does not exist.
```

cc @mario 


Discussion:
 Page not found

The page you are looking for does not exist!


-- This is what I get @MorrisJobke ?
Ah your link was wrong. Should be /categories/auth

Resolving patch:
diff --git a/nextcloudappstore/core/views.py b/nextcloudappstore/core/views.py
--- a/nextcloudappstore/core/views.py
+++ b/nextcloudappstore/core/views.py
@@ -219,7 +219,8 @@ def get_context_data(self, **kwargs):
         context['is_featured_category'] = self.kwargs \
             .get('is_featured_category', False)
         if category_id:
-            context['current_category'] = Category.objects.get(id=category_id)
+            context['current_category'] = get_object_or_404(Category,
+                                                            id=category_id)
         if self.search_terms:
             context['search_query'] = ' '.join(self.search_terms)
         context['url_params'] = self.url_params


Test patch:
Repository: nextcloud/appstore

Issue:
l10n: Remove string from Transifex
https://github.com/nextcloud/appstore/blob/25f19514911e1225ad2dd555346fd6b9d6ed3702/nextcloudappstore/core/models.py#L451

https://github.com/nextcloud/appstore/blob/25f19514911e1225ad2dd555346fd6b9d6ed3702/nextcloudappstore/core/models.py#L472

@bigcat88 These are non-valid strings for our Translators. Please remove them or adapt them.
l10n: Remove string from Transifex
https://github.com/nextcloud/appstore/blob/25f19514911e1225ad2dd555346fd6b9d6ed3702/nextcloudappstore/core/models.py#L451

https://github.com/nextcloud/appstore/blob/25f19514911e1225ad2dd555346fd6b9d6ed3702/nextcloudappstore/core/models.py#L472

@bigcat88 These are non-valid strings for our Translators. Please remove them or adapt them.


Discussion:

Resolving patch:
diff --git a/nextcloudappstore/core/models.py b/nextcloudappstore/core/models.py
--- a/nextcloudappstore/core/models.py
+++ b/nextcloudappstore/core/models.py
@@ -448,7 +448,7 @@ class AppApiReleaseDeployMethod(Model):
     )
 
     class Meta:
-        db_table = _("core_appapi_release_deploy_method")
+        db_table = "core_appapi_release_deploy_method"
         verbose_name = _("AppAPI release Deploy method")
         verbose_name_plural = _("AppAPI release Deploy methods")
 
@@ -469,7 +469,7 @@ class AppApiReleaseApiScope(Model):
     scope_name = CharField(max_length=32, verbose_name=_("Name of the API scope"))
 
     class Meta:
-        db_table = _("core_appapi_release_api_scopes")
+        db_table = "core_appapi_release_api_scopes"
         verbose_name = _("AppAPI release API Scope")
         verbose_name_plural = _("AppAPI release API Scopes")
 


Test patch:
Repository: opendatacube/datacube-core

Issue:
Inconsistent command line option spelling
Command line option to `datacube` app to specify configuration file is using underscore `_` case while two other multi-word options use dashes `-`

- `--log-file`
- `--log-queries`
- `--config_file` <-- Odd one out

Most other subcommands also use `-` case for multi-word options, it's a common patterns in CLI apps.

## Proposed changes

Rename to `--config-file` or to just `--config`



Discussion:

Resolving patch:
diff --git a/datacube/ui/click.py b/datacube/ui/click.py
--- a/datacube/ui/click.py
+++ b/datacube/ui/click.py
@@ -150,7 +150,7 @@ def _set_environment(ctx, param, value):
 logfile_option = click.option('--log-file', multiple=True, callback=_add_logfile,
                               is_eager=True, expose_value=False, help="Specify log file")
 #: pylint: disable=invalid-name
-config_option = click.option('--config_file', '-C', multiple=True, default='', callback=_set_config,
+config_option = click.option('--config', '--config_file', '-C', multiple=True, default='', callback=_set_config,
                              expose_value=False)
 
 #: pylint: disable=invalid-name


Test patch:
diff --git a/integration_tests/conftest.py b/integration_tests/conftest.py
--- a/integration_tests/conftest.py
+++ b/integration_tests/conftest.py
@@ -124,7 +124,7 @@ def global_integration_cli_args(integration_config_paths):
     The first arguments to pass to a cli command for integration test configuration.
     """
     # List of a config files in order.
-    return list(itertools.chain(*(('--config_file', f) for f in integration_config_paths)))
+    return list(itertools.chain(*(('--config', f) for f in integration_config_paths)))
 
 
 @pytest.fixture
Repository: opendatacube/datacube-core

Issue:
Unnecessary dependency on `pathlib` when running in python3
### Expected behaviour
Datacube shouldn't depend on unnecessary packages when running in Python 3.

### Actual behaviour
There's a dependency on `pathlib`, which is included in the Python 3 standard library, and so doesn't need to be installed.

This causes trouble on the NCI deployment when trying to load `stats` modules which use the `setuptools` entry_points for their registration. And returns error messages to users trying to load them.

### Steps to reproduce the behaviour
```
module load agdc-py3-prod agdc_statistics
dra547@raijin4:~ $ python
Python 3.6.3 | packaged by conda-forge | (default, Nov  4 2017, 10:10:56)
[GCC 4.8.2 20140120 (Red Hat 4.8.2-15)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import datacube_stats.statistics
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/g/data/v10/public/modules/agdc_statistics/0.9a7/lib/python3.6/site-packages/datacube_stats/statistics.py", line 769, in <module>
    STATS[entry_point.name] = entry_point.load()
  File "/g/data/v10/public/modules/agdc-py3-env/20171214/envs/agdc/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2404, in load
    self.require(*args, **kwargs)
  File "/g/data/v10/public/modules/agdc-py3-env/20171214/envs/agdc/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2427, in require
    items = working_set.resolve(reqs, env, installer, extras=self.extras)
  File "/g/data/v10/public/modules/agdc-py3-env/20171214/envs/agdc/lib/python3.6/site-packages/pkg_resources/__init__.py", line 870, in resolve
    raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'pathlib' distribution was not found and is required by datacube
>>>
```

### The Fix
Modify `setup.py` to use [platform specific dependencies](https://setuptools.readthedocs.io/en/latest/setuptools.html#declaring-platform-specific-dependencies) to only require `pathlib` when not running on python 3.


Discussion:

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -76,7 +76,7 @@
         'jsonschema',
         'netcdf4',
         'numpy',
-        'pathlib',
+        'pathlib;python_version<"3"',
         'psycopg2',
         'pypeg2',
         'python-dateutil',


Test patch:
Repository: opendatacube/datacube-core

Issue:
Drop Support for Python 2
I'd like to propose that future development on Data Cube Core stop supporting Python 2 after the beginning of February 2018.

We can continue to support Python 2 for bug fix releases of version 1.5.x, but beyond that it is an ongoing drain on the limited developer resources.


Discussion:
Quite likely an appropriate proposal. I support it in principal. We could suggest that someone else may like to take up the mantle for python 2 maintenance; and the Core devs will focus on python 3 from Feb onwards.

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -33,6 +33,7 @@
     name='datacube',
     version=versioneer.get_version(),
     cmdclass=versioneer.get_cmdclass(),
+    python_requires='>3.5.2',
 
     url='https://github.com/opendatacube/datacube-core',
     author='AGDC Collaboration',
@@ -53,10 +54,9 @@
         "Operating System :: POSIX :: Linux",
         "Operating System :: Microsoft :: Windows",
         "Programming Language :: Python",
-        "Programming Language :: Python :: 2",
-        "Programming Language :: Python :: 2.7",
         "Programming Language :: Python :: 3",
         "Programming Language :: Python :: 3.5",
+        "Programming Language :: Python :: 3.6",
         "Topic :: Scientific/Engineering :: GIS",
         "Topic :: Scientific/Engineering :: Information Analysis",
     ],
@@ -84,7 +84,6 @@
         'jsonschema',
         'netcdf4',
         'numpy',
-        'pathlib;python_version<"3"',
         'psycopg2',
         'pypeg2',
         'python-dateutil',


Test patch:
Repository: opendatacube/datacube-core

Issue:
Mislabeled architecture doc section
Section

Architecture Guide> "Virtual Products"

Is not about "virtual products", it describes storage, and should be integrated into storage section of the "Architecture Guide"

This file should be renamed:

https://github.com/opendatacube/datacube-core/blob/develop/docs/architecture/virtual.md

or merged into 

https://github.com/opendatacube/datacube-core/blob/develop/docs/architecture/storage.rst





Discussion:
I'll merge it in, working on it now.

Resolving patch:
diff --git a/datacube/api/grid_workflow.py b/datacube/api/grid_workflow.py
--- a/datacube/api/grid_workflow.py
+++ b/datacube/api/grid_workflow.py
@@ -145,7 +145,7 @@ def __init__(self, index, grid_spec=None, product=None):
 
         Either grid_spec or product must be supplied.
 
-        :param Index index: The database index to use.
+        :param datacube.index.Index index: The database index to use.
         :param GridSpec grid_spec: The grid projection and resolution
         :param str product: The name of an existing product, if no grid_spec is supplied.
         """
diff --git a/docs/conf.py b/docs/conf.py
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -61,6 +61,7 @@
     'sphinx.ext.viewcode',
     'sphinx.ext.intersphinx',
     'sphinx.ext.extlinks',
+    'sphinx.ext.mathjax',
     'sphinxcontrib.plantuml',
     'sphinx_click.ext',
     'click_utils'


Test patch:
Repository: opendatacube/datacube-core

Issue:
Pin rasterio >= 1.0.2
There are some issues with rasterio that are fixed with 1.0.2 (See: https://github.com/opendatacube/datacube-core/pull/531#pullrequestreview-143845097).

Files to change:
- setup.py
- requirements.txt
- rtd-environment.yml (this also needs the conda-forge/label/dev channel removed with the change)


Discussion:

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -104,7 +104,7 @@
         'pypeg2',
         'python-dateutil',
         'pyyaml',
-        'rasterio~=1.0',
+        'rasterio>=1.0.2',  # Multi-band re-project fixed in that version
         'singledispatch',
         'sqlalchemy',
         'toolz',


Test patch:
Repository: opendatacube/datacube-core

Issue:
Change default representation (__str__) of Dataset model
### Expected behaviour

Dataset should not show location=None where the URIs are non-file URI

### Actual behaviour

```
>>> print(dataset)
Dataset <id=aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa type=product_name location=None>
```
Code in `datacube/models/__init__.py`:
```
class Dataset(object):
...
    def __str__(self):
        return "Dataset <id={id} type={type} location={loc}>".format(id=self.id,
                                                                     type=self.type.name,
                                                                     loc=self.local_path)
```

### Steps to reproduce the behaviour

Index a dataset which has an s3 uri, or other non-file uri, call/trigger the `__repr__`/`__str__` methods the dataset.

### Environment information

Datacube version 1.6rc1+8.g6124b687
Datacube Deployment: GA production datacube against a development index to validate indexing s3 collections.



Discussion:

Resolving patch:
diff --git a/datacube/model/__init__.py b/datacube/model/__init__.py
--- a/datacube/model/__init__.py
+++ b/datacube/model/__init__.py
@@ -299,9 +299,10 @@ def __hash__(self):
         return hash(self.id)
 
     def __str__(self):
+        str_loc = 'not available' if not self.uris else self.uris[0]
         return "Dataset <id={id} type={type} location={loc}>".format(id=self.id,
                                                                      type=self.type.name,
-                                                                     loc=self.local_path)
+                                                                     loc=str_loc)
 
     def __repr__(self):
         return self.__str__()


Test patch:
Repository: opendatacube/datacube-core

Issue:
Extend datacube.model
There are several classes that should be implemented to replace python dictionaries to improve look and feel of the API
* **Tile** - to be used with `GridWorkflow`
* **Measurement** - returned from `model.Dataset.measurements`
* **SpectralDefinitions** - encapsulate spectral definition arrays for reflectance bands
* **FlagDefinitions** - encapsulate bit flag definitions for quality bands
Extend datacube.model
There are several classes that should be implemented to replace python dictionaries to improve look and feel of the API
* **Tile** - to be used with `GridWorkflow`
* **Measurement** - returned from `model.Dataset.measurements`
* **SpectralDefinitions** - encapsulate spectral definition arrays for reflectance bands
* **FlagDefinitions** - encapsulate bit flag definitions for quality bands


Discussion:

Resolving patch:
diff --git a/datacube/model/__init__.py b/datacube/model/__init__.py
--- a/datacube/model/__init__.py
+++ b/datacube/model/__init__.py
@@ -573,16 +573,6 @@ def _polygon_from_sources_extents(sources, geobox):
 GeoPolygon.from_sources_extents = _polygon_from_sources_extents
 
 
-class FlagsDefinition(object):
-    def __init__(self, flags_def_dict):
-        self.flags_def_dict = flags_def_dict
-
-
-class SpectralDefinition(object):
-    def __init__(self, spec_def_dict):
-        self.spec_def_dict = spec_def_dict
-
-
 class GridSpec(object):
     """
     Definition for a regular spatial grid


Test patch: