Skip to content

Commit

Permalink
Updates for flake8 and pytest workflow steps.
Browse files Browse the repository at this point in the history
  • Loading branch information
wd-mgreynolds committed Oct 26, 2023
1 parent 51974d9 commit b94b9d9
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 16 deletions.
4 changes: 2 additions & 2 deletions prism/commands/tables_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import sys
import click

from prism import *
from prism import (schema_compact, load_schema, upload_file, truncate_table)

logger = logging.getLogger("prismCLI")

Expand Down Expand Up @@ -182,7 +182,7 @@ def tables_edit(ctx, file, truncate):
table = p.tables_put(schema, truncate=truncate)

if table is None:
logger.error(f"Error updating table.")
logger.error("Error updating table.")
else:
logger.info(json.dumps(table, indent=2))

Expand Down
1 change: 0 additions & 1 deletion prism/data/invalid-schema.json

This file was deleted.

6 changes: 0 additions & 6 deletions prism/data/schema.csv

This file was deleted.

14 changes: 8 additions & 6 deletions prism/prism.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ def create_bearer_token(self):
self.bearer_token = r.json()["access_token"]
self.bearer_token_timestamp = time.time()
else:
logger.error(f"create bearer token failed: HTTP status code.")
# Error handling occurred in http_post, fail silently here.
self.bearer_token = None
self.bearer_token_timestamp = None

Expand Down Expand Up @@ -918,7 +918,7 @@ def buckets_create(
tables = self.tables_get(table_name=target_name, type_="full")

if tables["total"] == 0:
logger.error(f"table not found for bucket operation.")
logger.error(f"table {target_name} not found for bucket operation.")
return None

table = tables["data"][0]
Expand All @@ -940,7 +940,7 @@ def buckets_create(

bucket_schema = table_to_bucket_schema(compact_schema)

logger.debug(f"post: /buckets")
logger.debug("post: /buckets")
url = self.prism_endpoint + "/buckets"

data = {
Expand Down Expand Up @@ -984,7 +984,9 @@ def buckets_complete(self, bucket_id):
logger.debug(f"successfully completed wBucket {bucket_id}.")
return r.json()
elif r.status_code == 400:
logger.debug(f"error completing bucket")
# This is an error coming back from the API call and
# is actually valid JSON with an "error" attribute.
logger.debug("non-fatal error completing bucket")
return r.json()

return None
Expand Down Expand Up @@ -1241,7 +1243,7 @@ def dataChanges_activities_post(self, datachange_id, filecontainer_id=None):
logger.debug(f"successfully started data load task - id: {activity_id}")
return return_json
elif r.status_code == 400:
logger.error(f"error running data change task.")
logger.error("error running data change task.")
return r.json() # This is still valid JSON with the error.

return None
Expand Down Expand Up @@ -1535,7 +1537,7 @@ def truncate_table(p, table_id=None, table_name=None):
bucket = p.buckets_create(target_name=table_name, operation="TruncateAndInsert")

if bucket is None:
logger.error(f"Unable to truncate table - see log for details.")
logger.error("Unable to truncate table - see log for details.")
return None

bucket_id = bucket["id"]
Expand Down
2 changes: 1 addition & 1 deletion tests/test_prism.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@


def test_load_schema(schema_file):
schema = prism.load_schema(schema_file)
schema = prism.load_schema(file=schema_file)
assert type(schema) is dict

0 comments on commit b94b9d9

Please sign in to comment.