Skip to content

Commit

Permalink
fix flake8 issues
Browse files Browse the repository at this point in the history
  • Loading branch information
neumark committed Jun 22, 2023
1 parent bc69b2d commit 8f67f9d
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 30 deletions.
4 changes: 2 additions & 2 deletions engine/Dockerfile
Expand Up @@ -187,8 +187,8 @@ RUN --mount=type=cache,id=pip-cache,target=/root/.cache/pip \

# Install PyAthena for Amazon Athena SQLAlchemy-based FDW, as well as pandas
RUN --mount=type=cache,id=pip-cache,target=/root/.cache/pip \
pip install "PyAthena>=2.4.1" && \
pip install "pandas>=1.0.0"
pip install "PyAthena==2.25.2" && \
pip install "pandas==1.5.3"

# Install Google's Big Query SQLAlchemy dialect lib
RUN --mount=type=cache,id=pip-cache,target=/root/.cache/pip \
Expand Down
4 changes: 1 addition & 3 deletions splitgraph/cloud/models.py
Expand Up @@ -128,9 +128,7 @@ def to_external(self) -> External:
ingestion_schedule: Optional[IngestionSchedule] = None

if self.ingestionScheduleByNamespaceAndRepository:
schemas = {
tn: ts for tn, ts in self.ingestionScheduleByNamespaceAndRepository.schema_.items()
}
schemas = dict(self.ingestionScheduleByNamespaceAndRepository.schema_.items())
ingestion_schedule = IngestionSchedule(
schedule=self.ingestionScheduleByNamespaceAndRepository.schedule,
enabled=self.ingestionScheduleByNamespaceAndRepository.enabled,
Expand Down
2 changes: 1 addition & 1 deletion splitgraph/commandline/misc.py
Expand Up @@ -301,7 +301,7 @@ def _eval(command, args):
object_manager = ObjectManager(object_engine=engine, metadata_engine=engine)

command_locals = locals().copy()
command_locals.update({k: v for k, v in args})
command_locals.update(dict(args))

# The whole point of this function is to unsafely run Python code from the cmdline,
# so silence the Bandit warning.
Expand Down
10 changes: 3 additions & 7 deletions splitgraph/commandline/splitfile.py
Expand Up @@ -53,7 +53,7 @@ def build_c(splitfile, args, output_repository, layered_querying):
from splitgraph.core.repository import Repository
from splitgraph.splitfile.execution import execute_commands

args = {k: v for k, v in args}
args = dict(args)
click.echo("Executing Splitfile %s with arguments %r" % (splitfile.name, args))

if output_repository is None:
Expand Down Expand Up @@ -245,12 +245,8 @@ def rebuild_c(image_spec, update, against, layered_querying):
# Replace the sources used to construct the image with either the latest ones or the images specified by the user.
# This doesn't require us at this point to have pulled all the dependencies: the Splitfile executor will do it
# after we feed in the reconstructed and patched Splitfile.
deps = {k: v for k, v in image.provenance()}
new_images = (
{repo: repl_image for repo, repl_image in against}
if not update
else {repo: "latest" for repo, _ in deps.items()}
)
deps = dict(image.provenance())
new_images = dict(against) if not update else {repo: "latest" for repo, _ in deps.items()}
deps.update(new_images)

click.echo("Rerunning %s:%s against:" % (str(repository), image.image_hash))
Expand Down
4 changes: 1 addition & 3 deletions splitgraph/core/fragment_manager.py
Expand Up @@ -1355,9 +1355,7 @@ def _add_overlapping_objects(
# Go through all objects and see if they 1) come after any of our chosen objects and 2)
# overlap those objects' PKs (if they come after them)
original_order = {object_id: i for i, object_id in enumerate(all_objects)}
object_pk_dict = {
object_id: object_pk for object_id, object_pk in zip(all_objects, object_pks)
}
object_pk_dict = dict(zip(all_objects, object_pks))
objects_to_scan = set(filtered_objects)
for overlap_candidate in all_objects:
if overlap_candidate in objects_to_scan:
Expand Down
2 changes: 1 addition & 1 deletion splitgraph/core/image_manager.py
Expand Up @@ -42,7 +42,7 @@ def __call__(self) -> List[Image]:
return result

def _make_image(self, img_tuple: Any) -> Image:
r_dict = {k: v for k, v in zip(IMAGE_COLS, img_tuple)}
r_dict = dict(zip(IMAGE_COLS, img_tuple))
r_dict.update(repository=self.repository)
return Image(**r_dict)

Expand Down
9 changes: 4 additions & 5 deletions splitgraph/core/object_manager.py
Expand Up @@ -382,13 +382,12 @@ def make_objects_external(
partial_failure: Optional[IncompleteObjectUploadError] = None
try:
with switch_engine(self.object_engine):
successful = {
o: u
for o, u in external_handler.upload_objects(new_objects, self.metadata_engine)
}
successful = dict(
external_handler.upload_objects(new_objects, self.metadata_engine)
)
except IncompleteObjectUploadError as e:
partial_failure = e
successful = {o: u for o, u in zip(e.successful_objects, e.successful_object_urls)}
successful = dict(zip(e.successful_objects, e.successful_object_urls))

locations = [(o, u, handler) for o, u in successful.items()]
self.register_object_locations(locations)
Expand Down
2 changes: 1 addition & 1 deletion splitgraph/core/table.py
Expand Up @@ -492,7 +492,7 @@ def _generate_results():
)
)
for row in result:
yield {c: v for c, v in zip(columns, row)}
yield dict(zip(columns, row))

try:
yield _generate_results()
Expand Down
9 changes: 3 additions & 6 deletions splitgraph/ingestion/csv/__init__.py
Expand Up @@ -345,12 +345,9 @@ def get_table_options(
if not isinstance(tables, dict):
return {}

result = {
k: v
for k, v in tables.get(table_name, cast(Tuple[TableSchema, TableParams], ({}, {})))[
1
].items()
}
result = dict(
tables.get(table_name, cast(Tuple[TableSchema, TableParams], ({}, {})))[1].items()
)

# Set a default s3_object if we're using S3 and not HTTP
if "url" not in result:
Expand Down
2 changes: 1 addition & 1 deletion test/splitgraph/test_config.py
Expand Up @@ -536,7 +536,7 @@ def test_arg_flag_supercedes_env_var(fs_fast):

with patch.object(sys, "argv", mock_argv):
with patch_os_environ(mock_environ):
assert os.environ.get("SG_NAMESPACE", None) == "namespace-from-env-var"
assert os.environ.get("SG_NAMESPACE") == "namespace-from-env-var"
assert sys.argv[2] == "namespace-from-arg"

config = create_config_dict()
Expand Down

0 comments on commit 8f67f9d

Please sign in to comment.