Skip to content

Commit

Permalink
python linting
Browse files Browse the repository at this point in the history
  • Loading branch information
JosepSampe committed Jan 24, 2024
1 parent cc197bf commit ad2dab1
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 29 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ env:

jobs:

determine_runnable_jobs:
determine_runnable_test_jobs:
runs-on: ubuntu-latest
if: github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch'

Expand All @@ -34,8 +34,8 @@ jobs:
localhost_tests:
runs-on: ubuntu-latest
needs: determine_runnable_jobs
if: needs.determine_runnable_jobs.outputs.localhost == 'true'
needs: determine_runnable_test_jobs
if: needs.determine_runnable_test_jobs.outputs.localhost == 'true'

steps:
- name: Clone Lithops repository
Expand All @@ -57,8 +57,8 @@ jobs:
ibm_ce_cos_tests:
runs-on: ubuntu-latest
needs: determine_runnable_jobs
if: needs.determine_runnable_jobs.outputs.code_engine == 'true'
needs: determine_runnable_test_jobs
if: needs.determine_runnable_test_jobs.outputs.code_engine == 'true'

steps:
- name: Clone Lithops repository
Expand Down Expand Up @@ -118,4 +118,4 @@ jobs:
- name: Lint with flake8
run: |
flake8 lithops --count --max-line-length=180 --statistics
flake8 lithops --count --max-line-length=180 --statistics --ignore W605
9 changes: 3 additions & 6 deletions lithops/job/serialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,7 @@ def _module_inspect(self, obj):
seen = set()
mods = set()

if inspect.isfunction(obj) or (inspect.ismethod(obj) and
inspect.isfunction(obj.__func__)):
if inspect.isfunction(obj) or (inspect.ismethod(obj) and inspect.isfunction(obj.__func__)):
# The obj is the user's function
worklist.append(obj)

Expand All @@ -148,15 +147,13 @@ def _module_inspect(self, obj):
else:
# it is a user defined class
for k, v in inspect.getmembers(param):
if inspect.isfunction(v) or (inspect.ismethod(v) and
inspect.isfunction(v.__func__)):
if inspect.isfunction(v) or (inspect.ismethod(v) and inspect.isfunction(v.__func__)):
worklist.append(v)
else:
# The obj is the user's function but in form of a class
found_methods = []
for k, v in inspect.getmembers(obj):
if inspect.isfunction(v) or (inspect.ismethod(v) and
inspect.isfunction(v.__func__)):
if inspect.isfunction(v) or (inspect.ismethod(v) and inspect.isfunction(v.__func__)):
found_methods.append(k)
worklist.append(v)
if "__call__" not in found_methods:
Expand Down
2 changes: 1 addition & 1 deletion lithops/localhost/v2/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ def python_queue_consumer(


if __name__ == "__main__":
logger.info('*'*60)
logger.info('*' * 60)

worker_processes = int(sys.argv[1]) if len(sys.argv) > 1 else CPU_COUNT
service_port = int(sys.argv[2]) if len(sys.argv) > 2 else utils.find_free_port()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def get_message():
def extract_runtime_metadata(payload):
runtime_meta = get_runtime_metadata()
internal_storage = InternalStorage(payload['storage_config'])
status_key = payload['containerapp_name']+'.meta'
status_key = payload['containerapp_name'] + '.meta'
logger.info(f"Runtime metadata key {status_key}")
dmpd_response_status = json.dumps(runtime_meta)
internal_storage.put_data(status_key, dmpd_response_status)
Expand Down
2 changes: 1 addition & 1 deletion lithops/serverless/backends/code_engine/entry_point.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def extract_runtime_metadata(payload):
runtime_meta = get_runtime_metadata()

internal_storage = InternalStorage(payload)
status_key = '/'.join([JOBS_PREFIX, payload['runtime_name']+'.meta'])
status_key = '/'.join([JOBS_PREFIX, payload['runtime_name'] + '.meta'])
logger.info(f"Runtime metadata key {status_key}")
dmpd_response_status = json.dumps(runtime_meta)
internal_storage.put_data(status_key, dmpd_response_status)
Expand Down
8 changes: 4 additions & 4 deletions lithops/serverless/backends/k8s/k8s.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,10 +354,10 @@ def _get_nodes(self):
cpu_info = node.status.allocatable['cpu']

self.nodes.append({
"name": node.metadata.name,
"cpu": cpu_info,
"memory": node.status.allocatable['memory']
})
"name": node.metadata.name,
"cpu": cpu_info,
"memory": node.status.allocatable['memory']
})

def _create_workers(self, runtime_memory):
default_pod_config = yaml.load(config.POD, Loader=yaml.loader.SafeLoader)
Expand Down
2 changes: 1 addition & 1 deletion lithops/standalone/backends/aws_ec2/aws_ec2.py
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ def build_image(self, image_name, script_file, overwrite, extra_args=[]):
initial_vpc_data = self._load_ec2_data()
self.init()

build_vm = EC2Instance('building-image-'+image_name, self.config, self.ec2_client, public=True)
build_vm = EC2Instance('building-image-' + image_name, self.config, self.ec2_client, public=True)
build_vm.delete_on_dismantle = False
build_vm.create()
build_vm.wait_ready()
Expand Down
2 changes: 1 addition & 1 deletion lithops/standalone/backends/ibm_vpc/ibm_vpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ def build_image(self, image_name, script_file, overwrite, extra_args=[]):
self.config['floating_ip'] = fip
self.config['floating_ip_id'] = fip_id

build_vm = IBMVPCInstance('building-image-'+image_name, self.config, self.vpc_cli, public=True)
build_vm = IBMVPCInstance('building-image-' + image_name, self.config, self.vpc_cli, public=True)
build_vm.public_ip = self.config['floating_ip']
build_vm.instance_type = self.config['master_profile_name']
build_vm.delete_on_dismantle = False
Expand Down
15 changes: 8 additions & 7 deletions lithops/standalone/master.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,13 +348,14 @@ def get_workers(worker_instance_type, runtime_name):

def check_worker(worker):
if is_worker_free(worker):
free_workers.append((
worker.name,
worker.private_ip,
worker.instance_id,
worker.ssh_credentials,
worker.instance_type,
runtime_name
free_workers.append(
(
worker.name,
worker.private_ip,
worker.instance_id,
worker.ssh_credentials,
worker.instance_type,
runtime_name
)
)

Expand Down
2 changes: 1 addition & 1 deletion lithops/tests/test_map_reduce.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def test_chunks_bucket(self):
result = fexec.get_result(futures)
self.assertEqual(result, self.__class__.words_in_cos_files)

self.assertEqual(len(futures), len(TEST_FILES_URLS)*OBJ_CHUNK_NUMBER + 1)
self.assertEqual(len(futures), len(TEST_FILES_URLS) * OBJ_CHUNK_NUMBER + 1)

def test_chunks_bucket_one_reducer_per_object(self):
"""tests the ability to create a separate function invocation based on the following parameters, as well as
Expand Down

0 comments on commit ad2dab1

Please sign in to comment.