Skip to content

Commit

Permalink
filtered embedds from xml (#33)
Browse files Browse the repository at this point in the history
* filtered embedds from xml

* fixed typo

* patch version
  • Loading branch information
davidschober authored Apr 1, 2024
1 parent 82d0dfc commit 8182271
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 10 additions & 1 deletion nuldc/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
retries = urllib3.Retry(total=5,
backoff_factor=1,
status_forcelist=[429, 500, 502, 503, 504],
method_whitelist=['GET', 'POST'])
allowed_methods=['GET', 'POST'])

session = requests.Session()
adapter = HTTPAdapter(max_retries=retries)
Expand Down Expand Up @@ -176,8 +176,17 @@ def save_as_csv(headers, values, output_file):

def save_xml(data, output_file):
"""takes results as a list of dicts and writes them out to xml"""


# TODO DRY up this bit and sort_fields_and_values

ignore_fields = ['embedding', 'embedding_model']

data = [{key: value
for (key, value) in sorted(d.items())
if key not in ignore_fields} for d in data.get('data')]
xml = dicttoxml.dicttoxml(data, attr_type=False)

with open(output_file, 'wb') as xmlfile:
xmlfile.write(xml)

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "nuldc"
version = "0.10.0"
version = "0.10.1"
description = ""
authors = ["davidschober <davidschob@gmail.com>"]
license = "MIT"
Expand Down

0 comments on commit 8182271

Please sign in to comment.