Skip to content

Commit

Permalink
Fix code for tighter PEP8 checks
Browse files Browse the repository at this point in the history
Remove footprtins' historical style (it is not so bad after all).
  • Loading branch information
meunierlf committed Jan 12, 2023
1 parent 91d236a commit 9fc8fef
Show file tree
Hide file tree
Showing 4 changed files with 178 additions and 166 deletions.
52 changes: 26 additions & 26 deletions src/taylorism/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,36 +120,36 @@ class Worker(FootprintBase):
_abstract = True
_collector = ('worker',)
_footprint = dict(
attr = dict(
name = dict(
info = 'Name of the worker.',
optional = True,
default = None,
access = 'rwx',
attr=dict(
name=dict(
info='Name of the worker.',
optional=True,
default=None,
access='rwx',
),
memory = dict(
info = 'Memory that should be used by the worker (in MiB).',
optional = True,
default = 0.,
type = float,
memory=dict(
info='Memory that should be used by the worker (in MiB).',
optional=True,
default=0.,
type=float,
),
expected_time = dict(
info = 'How long the worker is expected to run (in s).',
optional = True,
default = 0.,
type = float,
expected_time=dict(
info='How long the worker is expected to run (in s).',
optional=True,
default=0.,
type=float,
),
scheduler_ticket = dict(
info = 'The slot number given by the scheduler (optional).',
optional = True,
default = None,
type = int,
scheduler_ticket=dict(
info='The slot number given by the scheduler (optional).',
optional=True,
default=None,
type=int,
),
scheduler_hooks = dict(
info = 'List of callbacks before starting effective task work.',
optional = True,
default = FPList(),
type = FPList,
scheduler_hooks=dict(
info='List of callbacks before starting effective task work.',
optional=True,
default=FPList(),
type=FPList,
),
)
)
Expand Down
110 changes: 55 additions & 55 deletions src/taylorism/examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,18 @@ class Sleeper(Worker):
"""

_footprint = dict(
info = "Sleeps.",
attr = dict(
sleeping_time = dict(
info = "Sleeping time in s.",
values = [0.001, 0.01, 0.1] + list(range(10)) + list(range(10, 65, 5)),
type = float,
info="Sleeps.",
attr=dict(
sleeping_time=dict(
info="Sleeping time in s.",
values=[0.001, 0.01, 0.1] + list(range(10)) + list(range(10, 65, 5)),
type=float,
),
wakeup_sentence = dict(
info = "What to say after sleep.",
optional = True,
access = 'rwx',
default = 'Hello !',
wakeup_sentence=dict(
info="What to say after sleep.",
optional=True,
access='rwx',
default='Hello !',
),
)
)
Expand All @@ -58,14 +58,14 @@ class Logarithmer(Worker):
an example of using shared numpy arrays among workers.
"""
_footprint = dict(
attr = dict(
row = dict(
info = "Index of the row of the array on which the Worker is supposed to work.",
type = int),
array = dict(
info = "The shared-memory array on which to work on.",
type = SharedNumpyArray,
access = 'rwx')
attr=dict(
row=dict(
info="Index of the row of the array on which the Worker is supposed to work.",
type=int),
array=dict(
info="The shared-memory array on which to work on.",
type=SharedNumpyArray,
access='rwx')
)
)

Expand All @@ -82,17 +82,17 @@ class Summer(Worker):
This needs and illustrates process-safetiness.
"""
_footprint = dict(
attr = dict(
value = dict(
info = "Value to be added by the worker.",
type = int),
shared_sum = dict(
info = "The shared-memory array on which to sum.",
type = SharedNumpyArray,
access = 'rwx'),
use_lock = dict(
info = "Whether to use the lock (thread-safe) or not (may lead to a wrong result !).",
type = bool)
attr=dict(
value=dict(
info="Value to be added by the worker.",
type=int),
shared_sum=dict(
info="The shared-memory array on which to sum.",
type=SharedNumpyArray,
access='rwx'),
use_lock=dict(
info="Whether to use the lock (thread-safe) or not (may lead to a wrong result !).",
type=bool)
)
)

Expand All @@ -114,31 +114,31 @@ class MatrixProducter(Worker):
Again, numpy matrix products may probably be more efficient...
"""
_footprint = dict(
attr = dict(
A = dict(
info = "The A shared-memory array matrix.",
type = SharedNumpyArray,
access = 'rwx'),
B = dict(
info = "The B shared-memory array matrix.",
type = SharedNumpyArray,
access = 'rwx'),
C = dict(
info = "The C shared-memory array matrix.",
type = SharedNumpyArray,
access = 'rwx'),
i1 = dict(
info = "The first index i of the the Worker is responsible for.",
type = int),
i2 = dict(
info = "The last index i of the the Worker is responsible for.",
type = int),
j1 = dict(
info = "The first index j of the the Worker is responsible for.",
type = int),
j2 = dict(
info = "The first index j of the the Worker is responsible for.",
type = int),
attr=dict(
A=dict(
info="The A shared-memory array matrix.",
type=SharedNumpyArray,
access='rwx'),
B=dict(
info="The B shared-memory array matrix.",
type=SharedNumpyArray,
access='rwx'),
C=dict(
info="The C shared-memory array matrix.",
type=SharedNumpyArray,
access='rwx'),
i1=dict(
info="The first index i of the the Worker is responsible for.",
type=int),
i2=dict(
info="The last index i of the the Worker is responsible for.",
type=int),
j1=dict(
info="The first index j of the the Worker is responsible for.",
type=int),
j2=dict(
info="The first index j of the the Worker is responsible for.",
type=int),
)
)

Expand Down
108 changes: 54 additions & 54 deletions src/taylorism/schedulers.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ class BaseScheduler(FootprintBase):
_abstract = True
_collector = ('scheduler',)
_footprint = dict(
attr = dict(
identity = dict(
info = "Scheduler identity.",
optional = True,
default = 'anonymous',
attr=dict(
identity=dict(
info="Scheduler identity.",
optional=True,
default='anonymous',
),
)
)
Expand Down Expand Up @@ -101,11 +101,11 @@ class NewLaxistScheduler(BaseScheduler):
"""No sorting is done !"""

_footprint = dict(
attr = dict(
nosort = dict(
alias = ('laxist', 'unsorted'),
values = (True,),
type = bool,
attr=dict(
nosort=dict(
alias=('laxist', 'unsorted'),
values=(True,),
type=bool,
),
)
)
Expand All @@ -124,10 +124,10 @@ class NewLimitedScheduler(BaseScheduler):

_abstract = True,
_footprint = dict(
attr = dict(
limit = dict(
values = ['threads', 'memory', 'mem', 'threads+memory'],
remap = dict(mem = 'memory'),
attr=dict(
limit=dict(
values=['threads', 'memory', 'mem', 'threads+memory'],
remap=dict(mem='memory'),
),
)
)
Expand Down Expand Up @@ -179,15 +179,15 @@ class NewMaxThreadsScheduler(NewLimitedScheduler):
_footprint = [
_binded_fpattr,
dict(
attr = dict(
limit = dict(
values = ['threads', 'processes'],
remap = dict(processes = 'threads'),
attr=dict(
limit=dict(
values=['threads', 'processes'],
remap=dict(processes='threads'),
),
max_threads = dict(
alias = ('maxpc', 'maxthreads'),
remap = {0: multiprocessing.cpu_count() / 2},
type = int,
max_threads=dict(
alias=('maxpc', 'maxthreads'),
remap={0: multiprocessing.cpu_count() / 2},
type=int,
),
)
)
Expand Down Expand Up @@ -217,30 +217,30 @@ class NewMaxMemoryScheduler(NewLimitedScheduler):
_footprint = [
_binded_fpattr,
dict(
attr = dict(
limit = dict(
values = ['memory', 'mem'],
remap = dict(mem = 'memory'),
attr=dict(
limit=dict(
values=['memory', 'mem'],
remap=dict(mem='memory'),
),
max_memory = dict(
info = "Amount of usable memroy (in MiB)",
optional = True,
type = float,
access = 'rwx',
max_memory=dict(
info="Amount of usable memroy (in MiB)",
optional=True,
type=float,
access='rwx',
),
memory_per_task = dict(
info = ("If a worker do not provide any information on memory, " +
"request at least *memory_per_task* MiB of memory."),
optional = True,
default = 2048.,
type = float,
memory_per_task=dict(
info=("If a worker do not provide any information on memory, " +
"request at least *memory_per_task* MiB of memory."),
optional=True,
default=2048.,
type=float,
),
memory_max_percentage = dict(
info = ("Max memory level as a fraction of the total" +
"system memory (used only if max_memroy is not provided)."),
optional = True,
default = 0.75,
type = float,
memory_max_percentage=dict(
info=("Max memory level as a fraction of the total" +
"system memory (used only if max_memroy is not provided)."),
optional=True,
default=0.75,
type=float,
),
)
)
Expand Down Expand Up @@ -293,14 +293,14 @@ class LongerFirstScheduler(NewMaxMemoryScheduler):
"""

_footprint = dict(
attr = dict(
limit = dict(
values = ['threads+memory'],
attr=dict(
limit=dict(
values=['threads+memory'],
),
max_threads = dict(
alias = ('maxpc', 'maxthreads'),
remap = {0: multiprocessing.cpu_count() / 2},
type = int,
max_threads=dict(
alias=('maxpc', 'maxthreads'),
remap={0: multiprocessing.cpu_count() / 2},
type=int,
),
)
)
Expand Down Expand Up @@ -338,10 +338,10 @@ class NewSingleOpenFileScheduler(NewMaxThreadsScheduler):
"""

_footprint = dict(
attr = dict(
singlefile = dict(
values = (True,),
type = bool,
attr=dict(
singlefile=dict(
values=(True,),
type=bool,
),
)
)
Expand Down
Loading

0 comments on commit 9fc8fef

Please sign in to comment.