Skip to content

Commit

Permalink
chore: update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
ingeridhellen committed Aug 25, 2023
1 parent 04faf51 commit 3a156c1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 30 deletions.
23 changes: 10 additions & 13 deletions dm_cli/dmss_api/model_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,19 @@
"""


from datetime import date, datetime # noqa: F401
from copy import deepcopy
import inspect
import io
import os
import pprint
import re
import tempfile
import uuid

from dateutil.parser import parse
from copy import deepcopy
from datetime import date, datetime # noqa: F401

from dm_cli.dmss_api.exceptions import (
ApiKeyError,
ApiAttributeError,
ApiKeyError,
ApiTypeError,
ApiValueError,
)
Expand Down Expand Up @@ -1249,11 +1247,12 @@ def deserialize_primitive(data, klass, path_to_item):
"string value, please set its type as `type: {}` in your "
"spec. That allows the value to be any type. "
)

# The string should be in iso8601 datetime format.
if not isinstance(data, str) or len(data) < 8:
raise ValueError("This is not a datetime")
parsed_datetime = datetime.fromisoformat(data)
if klass == datetime:
if len(data) < 8:
raise ValueError("This is not a datetime")
# The string should be in iso8601 datetime format.
parsed_datetime = parse(data)
date_only = (
parsed_datetime.hour == 0 and
parsed_datetime.minute == 0 and
Expand All @@ -1265,17 +1264,15 @@ def deserialize_primitive(data, klass, path_to_item):
raise ValueError("This is a date, not a datetime")
return parsed_datetime
elif klass == date:
if len(data) < 8:
raise ValueError("This is not a date")
return parse(data).date()
return parsed_datetime.date()
else:
converted_value = klass(data)
if isinstance(data, str) and klass == float:
if str(converted_value) != data:
# '7' -> 7.0 -> '7.0' != '7'
raise ValueError('This is not a float')
return converted_value
except (OverflowError, ValueError) as ex:
except ValueError as ex:
# parse can raise OverflowError
raise ApiValueError(
"{0}Failed to parse {1} as {2}".format(
Expand Down
18 changes: 5 additions & 13 deletions dm_cli/import_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
from uuid import uuid4

import typer
from progress.bar import IncrementalBar
from rich.console import Console
from rich.text import Text
from tqdm import tqdm

from dm_cli.state import state

Expand Down Expand Up @@ -95,11 +95,7 @@ def import_package_tree(package: Package, destination: str) -> None:
package.traverse_package(lambda package: documents_to_upload.append(package.to_dict()))

files_to_upload = {}
with IncrementalBar(
f"\tImporting documents of type 'File' from {package.name}",
max=len(documents_to_upload),
suffix="%(percent).0f%% - [%(eta)ds/%(elapsed)ds]",
) as bar:
with tqdm(documents_to_upload, desc=f"Importing documents of type 'File' from {package.name}") as bar:
for document in documents_to_upload:
if isinstance(document, File):
try:
Expand All @@ -111,13 +107,9 @@ def import_package_tree(package: Package, destination: str) -> None:
text = Text(str(error))
console.print(text, style="red1")
raise typer.Exit(code=1)
bar.next()
bar.update()

with IncrementalBar(
f"\tImporting {package.name}",
max=len(documents_to_upload),
suffix="%(percent).0f%% - [%(eta)ds/%(elapsed)ds]",
) as bar:
with tqdm(documents_to_upload, desc=f"Importing {package.name}") as bar:
for document in documents_to_upload:
if not isinstance(document, File):
document = replace_file_addresses(document, data_source, files_to_upload)
Expand All @@ -129,4 +121,4 @@ def import_package_tree(package: Package, destination: str) -> None:
text = Text(str(error))
console.print(text, style="red1")
raise typer.Exit(code=1)
bar.next()
bar.update()
6 changes: 2 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
pyperclip>=1.8.2
requests>=2.31.0
emoji>=2.6.0
progress>=1.6
emoji>=2.8.0
tqdm>=4.66.1
frozendict>=2.3.8
typing_extensions>=4.7.1
python-dateutil>=2.8.2
typer[all]>=0.9.0

0 comments on commit 3a156c1

Please sign in to comment.