anon-iclr-submission/benchname-bug-localization huggingface dataset:
Repository: mjordan/islandora_workbench
Issue: KeyError Due to formatted_text Key

[This line](https://github.com/mjordan/islandora_workbench/blob/b2fd24cc03321dd3a5aa3f677a913c2cf134520d/workbench_fields.py#L189C22-L189C80) causes a KeyError as it doesn't check for the existence of the `'formatted_text'` key in the `field_name` dictionary. We can instead change it to 

```python
if 'formatted_text' in field_definitions[field_name] and field_definitions[field_name]['formatted_text'] is True:
```

Changed files:
workbench_fields.py

diff --git a/workbench_fields.py b/workbench_fields.py
index 8225bfd..a3c85dc 100644
--- a/workbench_fields.py
+++ b/workbench_fields.py
@@ -186,7 +186,7 @@ class SimpleField():
                     entity[field_name] = field_values
                 else:
                     row[field_name] = truncate_csv_value(field_name, row['node_id'], field_definitions[field_name], row[field_name])
-                    if field_definitions[field_name]['formatted_text'] is True:
+                    if 'formatted_text' in field_definitions[field_name] and field_definitions[field_name]['formatted_text'] is True:
                         entity[field_name] = [{'value': row[field_name], 'format': text_format}]
                     else:
                         entity[field_name] = [{'value': row[field_name]}]
Repository: mjordan/islandora_workbench
Issue: Create Media Does Not Work with Standalone Media URL

https://github.com/mjordan/islandora_workbench/blob/3590667e460fb6fed3a0d64ca2a15103cf1cfd1b/workbench_utils.py#L3348C8-L3348C46

will result in the whole routine failing if `standalone_media_url` is `true` in the configuration file.  We could instead replace this with

`media_endpoint_path = '/entity/media?_format=json' if config['standalone_media_url']  else '/entity/media'`

Changed files:
workbench_utils.py

diff --git a/workbench_utils.py b/workbench_utils.py
index f7e066e..5123875 100644
--- a/workbench_utils.py
+++ b/workbench_utils.py
@@ -3345,7 +3345,7 @@ def create_media(config, filename, file_fieldname, node_id, csv_row, media_use_t
                 media_track_field_data[0]['default'] = True
                 media_json[media_track_field_name_parts[2]] = media_track_field_data
 
-        media_endpoint_path = '/entity/media'
+        media_endpoint_path = '/entity/media?_format=json' if config['standalone_media_url']  else '/entity/media'
         media_headers = {
             'Content-Type': 'application/json'
         }
Repository: mjordan/islandora_workbench
Issue: Workbench Fails if Temp File Already Exists

The logic below is a bit confusing. Recall that `input_csv` is a (at the moment, proposed) path of the data in a temp directory.  It seems to be working when a file at path `input_csv` does not already exist, but it will not work if, say, two consecutive runs of Workbench are completed back-to-back (in which case the OS doesn't necessarily delete the temp files). 

https://github.com/mjordan/islandora_workbench/blob/017d89434fcd5de8147a3b40668e555504720def/workbench_utils.py#L3597C1-L3604

We could instead change it to
```python
elif file_path.startswith('http') is True:
        input_csv_path = get_extracted_csv_file_path(config)
        if os.path.exists(input_csv_path):
            os.remove(input_csv_path)
        get_csv_from_google_sheet(config)
    elif file_path.endswith('.xlsx') is True:
        input_csv_path = get_extracted_csv_file_path(config)
        if os.path.exists(input_csv_path):
            os.remove(input_csv_path)
        get_csv_from_excel(config)
```
so that the code proceeds in both cases, but only after deleting the temp file if it already exists. 

Changed files:
workbench_utils.py

diff --git a/workbench_utils.py b/workbench_utils.py
index 1f7bab9..e9a2aeb 100644
--- a/workbench_utils.py
+++ b/workbench_utils.py
@@ -3596,12 +3596,14 @@ def get_csv_data(config, csv_file_target='node_fields', file_path=None):
         input_csv_path = file_path
     elif file_path.startswith('http') is True:
         input_csv_path = get_extracted_csv_file_path(config)
-        if not os.path.exists(input_csv_path):
-            get_csv_from_google_sheet(config)
+        if os.path.exists(input_csv_path):
+            os.remove(input_csv_path)
+        get_csv_from_google_sheet(config)
     elif file_path.endswith('.xlsx') is True:
         input_csv_path = get_extracted_csv_file_path(config)
-        if not os.path.exists(input_csv_path):
-            get_csv_from_excel(config)
+        if os.path.exists(input_csv_path):
+            os.remove(input_csv_path)
+        get_csv_from_excel(config)
     else:
         input_csv_path = os.path.join(config['input_dir'], file_path)
Repository: geoportail-luxembourg/geoportailv3
Issue: route /wms is in conflict with something undefined.

I'll change the route name in geoportailv3


Changed files:
geoportailv3/__init__.py

diff --git a/geoportailv3/__init__.py b/geoportailv3/__init__.py
index 25a00527..3adaee19 100644
--- a/geoportailv3/__init__.py
+++ b/geoportailv3/__init__.py
@@ -97,7 +97,7 @@ def main(global_config, **settings):
     add_interface(config, interface_type=INTERFACE_TYPE_NGEO_CATALOGUE)
 
     config.add_route('getuserinfo', '/getuserinfo')
-    config.add_route('wms', '/wms')
+    config.add_route('wms', '/ogcproxywms')
     config.add_route('qr', '/qr')
     config.add_route('getfeatureinfo', '/getfeatureinfo')
     config.add_route('getpoitemplate', '/getpoitemplate')
Repository: oemof/oemof-thermal
Issue: Data in csp example cannot be found

The path in the scripts is given in uppercase letters, therefore the files cannot be found. 

Changed files:
examples/concentrating_solar_power/csp_collector_plot_example.py, examples/concentrating_solar_power/csp_plant_example.py

diff --git a/examples/concentrating_solar_power/csp_collector_plot_example.py b/examples/concentrating_solar_power/csp_collector_plot_example.py
index 8dc6d22..0764c2e 100644
--- a/examples/concentrating_solar_power/csp_collector_plot_example.py
+++ b/examples/concentrating_solar_power/csp_collector_plot_example.py
@@ -9,11 +9,11 @@ import matplotlib.pyplot as plt
 
 # precaluculation #
 
-dataframe = pd.read_csv('CSP_data/data_Muscat_22_8.csv', sep=';')
+dataframe = pd.read_csv('csp_data/data_Muscat_22_8.csv', sep=';')
 dataframe['Datum'] = pd.to_datetime(dataframe['Datum'])
-df_temp_amb_series = pd.read_csv('CSP_data/data_Muscat_22_8_midday.csv',
+df_temp_amb_series = pd.read_csv('csp_data/data_Muscat_22_8_midday.csv',
                                  sep=';')
-temp_amb_series = pd.read_csv('CSP_data/temp_ambience.csv', sep=';')['t_amb']
+temp_amb_series = pd.read_csv('csp_data/temp_ambience.csv', sep=';')['t_amb']
 
 # parameters for the precalculation
 periods = 24
diff --git a/examples/concentrating_solar_power/csp_plant_example.py b/examples/concentrating_solar_power/csp_plant_example.py
index 26716d4..542e07f 100644
--- a/examples/concentrating_solar_power/csp_plant_example.py
+++ b/examples/concentrating_solar_power/csp_plant_example.py
@@ -15,7 +15,7 @@ import oemof.outputlib as outputlib
 
 # precaluculation #
 
-dataframe = pd.read_csv('CSP_data/data_CSP.csv', sep=';')
+dataframe = pd.read_csv('csp_data/data_CSP.csv', sep=';')
 dataframe['Datum'] = pd.to_datetime(dataframe['Datum'])
 
 # parameters for the precalculation
Repository: geoportail-luxembourg/geoportailv3
Issue: styling is lost when copying line

when copying a line from drawing to mymaps, the styling is lost and can even not be changed / stored afterwards


Changed files:
geoportailv3/mymaps.py

diff --git a/geoportailv3/mymaps.py b/geoportailv3/mymaps.py
index 3b3d1fb3..145b8289 100644
--- a/geoportailv3/mymaps.py
+++ b/geoportailv3/mymaps.py
@@ -138,7 +138,8 @@ class Feature(Base):
         self.is_circle = feature.properties.get('isCircle')
         self.show_orientation = feature.properties.get('showOrientation')
         linestyle = feature.properties.get('linestyle')
-        self.linestyle = 0 if linestyle == 'plain' else 1
+        self.linestyle = 0 if linestyle == 'plain' else 1\\
+            if linestyle == 'dashed' else 2
         self.shape = feature.properties.get('shape')
         size = feature.properties.get('size')
         self.size = size if size is not None and unicode(size).isnumeric()\\
@@ -220,7 +221,8 @@ class Feature(Base):
                           isLabel=self.is_label,
                           isCircle=self.is_circle,
                           showOrientation=self.show_orientation,
-                          linestyle=self.linestyle,
+                          linestyle='plain' if self.linestyle == 0
+                          else 'dashed' if self.linestyle == 1 else 'dotted',
                           id=self.id,
                           symbolId=self.symbol_id,
                           angle=self.angle if self.angle is not None else 0,
Repository: geoportail-luxembourg/geoportailv3
Issue: get feature info

When a feature is selected and the user clicks in the map inside an area without any feature, the current selected feature should be deselected.


Changed files:
geoportailv3/views/getfeatureinfo.py

diff --git a/geoportailv3/views/getfeatureinfo.py b/geoportailv3/views/getfeatureinfo.py
index 055130e7..c3320a04 100644
--- a/geoportailv3/views/getfeatureinfo.py
+++ b/geoportailv3/views/getfeatureinfo.py
@@ -372,7 +372,7 @@ class Getfeatureinfo(object):
         elif bbox is not None:
             body['geometry'] = bbox
             body['geometryType'] = 'esriGeometryEnvelope'
-            body['spatialRel'] = 'esriSpatialRelEnvelopeIntersects'
+            body['spatialRel'] = 'esriSpatialRelIntersects'
         else:
             return []
Repository: geoportail-luxembourg/geoportailv3
Issue: Shorturl fails when user is logged in

[Shorturl service](https://github.com/camptocamp/c2cgeoportal/blob/master/c2cgeoportal/views/shortener.py#L108) complains 
`AttributeError: 'O' object has no attribute 'email'`

The email user attribute is actually named `mail` ! This is a problem in C2C


Changed files:
geoportailv3/views/authentication.py

diff --git a/geoportailv3/views/authentication.py b/geoportailv3/views/authentication.py
index 250f24d0..7c724318 100644
--- a/geoportailv3/views/authentication.py
+++ b/geoportailv3/views/authentication.py
@@ -33,6 +33,7 @@ def get_user_from_request(request):
         user = O()
         user.id = 0
         user.username = username
+        user.email = None
         connector = get_ldap_connector(request)
         cm = connector.manager
Repository: sintef/dlite
Issue: Recursive directory creation for unit registry cache

Discovered in PR #494 that the user cache directory does not work in Windows. This seems to be because the `os.mkdir()` function used in  `units.prepare_cache_file_path()` does not create nested directories. Instead, `os.makedirs()` should be used.

Changed files:
bindings/python/triplestore/units.py

diff --git a/bindings/python/triplestore/units.py b/bindings/python/triplestore/units.py
index 92b262b2..dc8d97af 100644
--- a/bindings/python/triplestore/units.py
+++ b/bindings/python/triplestore/units.py
@@ -63,7 +63,7 @@ def prepare_cache_file_path(filename: str) -> str:
     """Return cache file name."""
     cache_directory = user_cache_dir("dlite")
     if not os.path.exists(cache_directory):
-        os.mkdir(cache_directory)
+        os.makedirs(cache_directory)
     return os.path.join(cache_directory, filename)
 
 
@@ -81,11 +81,11 @@ def get_pint_registry(sources=('qudt', ), force_recreate=False) -> UnitRegistry:
     """
     registry_file_path = prepare_cache_file_path("pint_unit_registry.txt")
     if force_recreate or not os.path.exists(registry_file_path):
-        with open(registry_file_path, "w") as f:
+        with open(registry_file_path, "w", encoding="utf8") as f:
             f.write("\\n".join(pint_prefix_lines()) + "\\n")
         for source in sources:
             pint_registry_lines = pint_registry_lines_from_qudt()
-            with open(registry_file_path, "a") as f:
+            with open(registry_file_path, "a", encoding="utf8") as f:
                 f.write("\\n".join(pint_registry_lines) + "\\n")
 
     ureg = UnitRegistry(registry_file_path)
Repository: city-of-helsinki/linkedevents
Issue: Stop Lippupiste importer from updating past events

The importer is importing data for past events daily. This is unnecessary. 

Change the importer so that it does not import past data.

Changed files:
events/importer/lippupiste.py

diff --git a/events/importer/lippupiste.py b/events/importer/lippupiste.py
index f7e420c..693949f 100644
--- a/events/importer/lippupiste.py
+++ b/events/importer/lippupiste.py
@@ -458,6 +458,8 @@ class LippupisteImporter(Importer):
         events = super_event.sub_events.filter(deleted=False)
         if not events.exists():
             return
+        # values that should be updated in super-event
+        update_dict = {}
         # name superevent by common part of the subevent names
         names = []
         # only one language existed in feed, therefore we save the common part of *all* names to *all* languages
@@ -473,14 +475,20 @@ class LippupisteImporter(Importer):
             lang = lang[0]
             lang = lang.replace('-', '_')
             if any([getattr(subevent, 'name_'+lang) for subevent in events]):
-                setattr(super_event, 'name_'+lang, super_event_name)
+                update_dict['name_'+lang] = super_event_name
         first_event = events.order_by('start_time').first()
-        super_event.start_time = first_event.start_time
-        super_event.has_start_time = first_event.has_start_time
+        update_dict['start_time'] = first_event.start_time
+        update_dict['has_start_time'] = first_event.has_start_time
+
         last_event = events.order_by('-end_time').first()
-        super_event.end_time = last_event.end_time
-        super_event.has_end_time = last_event.has_end_time
-        super_event.save()
+        update_dict['end_time'] = last_event.end_time
+        update_dict['has_end_time'] = last_event.has_end_time
+
+        if any([value != getattr(super_event, key) for key, value in update_dict.items()]):
+            # if something changed, update
+            for key, value in update_dict.items():
+                setattr(super_event, key, value)
+            super_event.save()
 
     def _synch_events(self, events):
         event_list = sorted(events.values(), key=lambda x: x['start_time'])
Repository: solvebio/solvebio-python
Issue: Queries are evaluated twice on failure in some cases

A query will be sent twice when in the interactive shell if the query raises an exception (in the case of an invalid filter).

Example:

```
$ solvebio
>>> Dataset.retrieve('ClinVar/ClinVar').query().filter(review_status_star__in=[])
```


Changed files:
solvebio/query.py

diff --git a/solvebio/query.py b/solvebio/query.py
index fd90252..13be6d5 100644
--- a/solvebio/query.py
+++ b/solvebio/query.py
@@ -8,6 +8,7 @@ from .utils.tabulate import tabulate
 
 import copy
 import logging
+from .errors import SolveError
 logger = logging.getLogger('solvebio')
 
 
@@ -221,7 +222,8 @@ class Query(object):
             limit=float('inf'),
             page_size=DEFAULT_PAGE_SIZE,
             result_class=dict,
-            debug=False):
+            debug=False,
+            error=None):
         """
         Creates a new Query object.
 
@@ -243,6 +245,7 @@ class Query(object):
         self._result_class = result_class
         self._fields = fields
         self._debug = debug
+        self._error = error
 
         if filters:
             if isinstance(filters, Filter):
@@ -421,6 +424,11 @@ class Query(object):
         return rv
 
     def __repr__(self):
+        # Check that Query object does not have any previous errors
+        # otherwise, raise the error.
+        if self._error:
+            raise self._error
+
         if len(self) == 0:
             return u'Query returned 0 results.'
 
@@ -434,6 +442,12 @@ class Query(object):
             logger.debug('warmup (__getattr__: %s)' % key)
             self.execute()
 
+        # Check that Query object does not have any previous errors
+        # otherwise, raise the error.
+        # execute() sets the error, so the check is placed after it.
+        if self._error:
+            raise self._error
+
         if key in self._response:
             return self._response[key]
 
@@ -597,7 +611,14 @@ class Query(object):
 
         logger.debug('executing query. from/limit: %6d/%d' %
                      (_params['offset'], _params['limit']))
-        self._response = client.post(self._data_url, _params)
+
+        # If the request results in a SolveError (ie bad filter) set the error.
+        try:
+            self._response = client.post(self._data_url, _params)
+        except SolveError as e:
+            self._error = e
+            raise
+
         logger.debug('query response took: %(took)d ms, total: %(total)d'
                      % self._response)
         return _params, self._response
Repository: solvebio/solvebio-python
Issue: Add support for login domains

`solvebio login` should prompt for the user's domain in addition to their email/password.


Changed files:
solvebio/test/test_login.py, solvebio/cli/auth.py

diff --git a/solvebio/cli/auth.py b/solvebio/cli/auth.py
index 2befb50..f9c9fc1 100644
--- a/solvebio/cli/auth.py
+++ b/solvebio/cli/auth.py
@@ -24,10 +24,11 @@ def _ask_for_credentials():
     """
     Asks the user for their email and password.
     """
-    _print_msg('Enter your SolveBio credentials')
+    _print_msg('Please enter your SolveBio credentials')
+    domain = input('Domain (e.g. <domain>.solvebio.com): ')
     email = input('Email: ')
     password = getpass.getpass('Password (typing will be hidden): ')
-    return (email, password)
+    return (domain, email, password)
 
 
 def _send_install_report():
@@ -50,17 +51,18 @@ def _send_install_report():
 
 def login(*args):
     """
-    Prompt user for login information (email/password).
-    Email and password are used to get the user's API key.
+    Prompt user for login information (domain/email/password).
+    Domain, email and password are used to get the user's API key.
     """
-    email, password = _ask_for_credentials()
+    domain, email, password = _ask_for_credentials()
 
-    if not email or not password:
-        print("Email and password are both required.")
+    if not all([domain, email, password]):
+        print("Domain, email, and password are all required.")
         return False
 
     try:
         response = client.post('/v1/auth/token', {
+            'domain': domain.replace('.solvebio.com', ''),
             'email': email,
             'password': password
         })
diff --git a/solvebio/test/test_login.py b/solvebio/test/test_login.py
index 9547c3f..dfd2395 100644
--- a/solvebio/test/test_login.py
+++ b/solvebio/test/test_login.py
@@ -28,7 +28,8 @@ class TestLogin(unittest.TestCase):
         # temporarily replace with dummy methods for testing
         self._ask_for_credentials = auth._ask_for_credentials
         self.delete_credentials = auth.delete_credentials
-        auth._ask_for_credentials = lambda login=None: ('fake@foo.bar',
+        auth._ask_for_credentials = lambda login=None: ('mydomain',
+                                                        'fake@foo.bar',
                                                         'p4ssw0rd')
         auth.delete_credentials = lambda: None
Repository: solvebio/solvebio-python
Issue: [Vaults] create_folder ignores path kwarg

The path kwarg is ingored in create_folder and the folder is just created at the root.

```
# this just creates my_new_folder in vault root
vault.create_folder('my_new_folder', path='/some/path')
```



Changed files:
solvebio/resource/vault.py

diff --git a/solvebio/resource/vault.py b/solvebio/resource/vault.py
index 5c06664..ae0b761 100644
--- a/solvebio/resource/vault.py
+++ b/solvebio/resource/vault.py
@@ -129,8 +129,16 @@ class Vault(CreateableAPIResource,
     def ls(self, **params):
         return self._object_list_helper(**params)
 
+    def _get_parent_folder(self, path):
+        from solvebio import Object
+        return Object.get_by_full_path(
+            ':'.join([self.full_path, path]),
+            assert_type='folder',
+            client=self._client
+        )
+
     def create_dataset(self, name, **params):
-        from solvebio import Dataset, Object
+        from solvebio import Dataset
 
         params['vault_id'] = self.id
         path = params.pop('path', None)
@@ -138,11 +146,7 @@ class Vault(CreateableAPIResource,
         if path == '/' or path is None:
             params['vault_parent_object_id'] = None
         else:
-            parent_object = Object.get_by_full_path(
-                ':'.join([self.full_path, path]),
-                assert_type='folder',
-                client=self._client
-            )
+            parent_object = self._get_parent_folder(path)
             params['vault_parent_object_id'] = parent_object.id
 
         params['name'] = name
@@ -151,6 +155,11 @@ class Vault(CreateableAPIResource,
     def create_folder(self, filename, **params):
         from solvebio import Object
 
+        path = params.pop('path', None)
+        if path and path != '/':
+            parent_object = self._get_parent_folder(path)
+            params['parent_object_id'] = parent_object.id
+
         params.update({
             'filename': filename,
             'vault_id': self.id,
Repository: solvebio/solvebio-python
Issue: [DashAuth] Specify cookie `max_age` to prevent immediate expiry

Currently, the `max_age` parameter is not set, resulting in the immediate expiry of the cookies. This forces users to always log in whenever they close their browsers. One solution would be to set the `max_age` to a week in `SolveBioAuth`.

Related: solvebio/www.solvebio.com#1580

Changed files:
solvebio/contrib/dash/solvebio_auth.py

diff --git a/solvebio/contrib/dash/solvebio_auth.py b/solvebio/contrib/dash/solvebio_auth.py
index aaeaf94..8f90a7c 100644
--- a/solvebio/contrib/dash/solvebio_auth.py
+++ b/solvebio/contrib/dash/solvebio_auth.py
@@ -20,6 +20,7 @@ class SolveBioAuth(OAuthBase):
     AUTH_COOKIE_NAME = 'dash_solvebio_auth'
     TOKEN_COOKIE_NAME = 'solvebio_oauth_token'
 
+    DEFAULT_TOKEN_COOKIE_MAX_AGE = 60 * 60 * 24 * 7
     DEFAULT_SOLVEBIO_URL = 'https://my.solvebio.com'
     DEFAULT_GRANT_TYPE = 'authorization_code'
 
@@ -54,6 +55,8 @@ class SolveBioAuth(OAuthBase):
         self._oauth_client_secret = kwargs.get('client_secret')
         self._oauth_grant_type = \\
             kwargs.get('grant_type') or self.DEFAULT_GRANT_TYPE
+        self.token_cookie_max_age = kwargs.get(
+            'max_age', self.DEFAULT_TOKEN_COOKIE_MAX_AGE)
 
         if self._oauth_grant_type == 'implicit':
             self._oauth_response_type = 'token'
@@ -177,7 +180,7 @@ class SolveBioAuth(OAuthBase):
             response=response,
             name=self.TOKEN_COOKIE_NAME,
             value=oauth_token,
-            max_age=None
+            max_age=self.token_cookie_max_age
         )
 
         return response
Repository: solvebio/solvebio-python
Issue: [Windows] Fix login mechanism on Windows ($HOME not set)

On windows we should check a different environment variable for the home directory in the netrc module.


Changed files:
solvebio/cli/credentials.py

diff --git a/solvebio/cli/credentials.py b/solvebio/cli/credentials.py
index b3cf83c..88bf5ed 100644
--- a/solvebio/cli/credentials.py
+++ b/solvebio/cli/credentials.py
@@ -20,11 +20,21 @@ class netrc(_netrc):
     """
     @staticmethod
     def path():
+        if os.name == 'nt':
+            # Windows
+            path = '~\\\\_solvebio\\\\credentials'
+        else:
+            # *nix
+            path = '~/.solvebio/credentials'
 
         try:
-            path = os.path.join(os.environ['HOME'], '.solvebio', 'credentials')
+            path = os.path.expanduser(path)
         except KeyError:
-            raise IOError("Could not find credentials file: $HOME is not set")
+            # os.path.expanduser can fail when $HOME is undefined and
+            # getpwuid fails. See http://bugs.python.org/issue20164
+            raise IOError(
+                "Could not find any home directory for '{0}'"
+                .format(path))
 
         if not os.path.isdir(os.path.dirname(path)):
             os.makedirs(os.path.dirname(path))
Repository: solvebio/solvebio-python
Issue: Dataset export of a query requires a limit

I'm trying to download all of HGNC but with just 2 fields and following the instructions in the new developer docs.

```
In [9]: dataset = Dataset.retrieve('HGNC/3.0.0-2017-03-01/HGNC')

In [10]: query = dataset.query(fields=['gene_symbol', 'name'])

In [11]: export = query.export(format='csv',follow=True)
```

results in
`SolveError: Bad request. {u'limit': [u"'limit' must be between 1 and 1000000"]}`

It seems that like if I can download the entire dataset with just Dataset.retrieve().export, I should be able to do the same with a subset of the fields? 
The download works if I set
`query = dataset.query(fields=['gene_symbol', 'name'], limit=100000)`

Changed files:
solvebio/query.py

diff --git a/solvebio/query.py b/solvebio/query.py
index e9d2384..82930c7 100644
--- a/solvebio/query.py
+++ b/solvebio/query.py
@@ -648,12 +648,17 @@ class Query(object):
     def export(self, format='json', follow=True, limit=None):
         from solvebio import DatasetExport
 
-        if not limit and self._limit < float('inf'):
-            limit = self._limit
-        params = self._build_query(limit=limit)
+        params = self._build_query()
         params.pop('offset', None)
         params.pop('ordering', None)
 
+        # if limit is not set use max limit
+        if not limit and self._limit < float('inf'):
+            limit = self._limit
+
+        if limit:
+            params['limit'] = limit
+
         export = DatasetExport.create(
             dataset_id=self._dataset_id,
             format=format,