Skip to content

Commit e9db879

Browse files
authored
lint: formatting (#7)
* lint: formatting Signed-off-by: vsoch <vsoch@users.noreply.github.com>
1 parent d1e486d commit e9db879

File tree

17 files changed

+116
-128
lines changed

17 files changed

+116
-128
lines changed

.github/workflows/deploy.yml

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
name: deploy
22

33
on:
4+
pull_request: []
45
push:
56
branches:
67
- master
@@ -9,17 +10,22 @@ jobs:
910
docker-deploy:
1011
runs-on: ubuntu-latest
1112
env:
12-
CONTAINER: quay.io/vanessa/cdb
13+
CONTAINER: ghcr.io/vsoch/cdb
1314
steps:
14-
- uses: actions/checkout@v2
15+
- uses: actions/checkout@v4
1516
- name: Build Docker Image
1617
run: docker build -f Dockerfile.base -t "${CONTAINER}" .
17-
- name: Log In to Quay.io
18-
env:
19-
DOCKER_USER: ${{ secrets.DOCKER_USER }}
20-
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
21-
run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login quay.io -u ${{ secrets.DOCKER_USER }} --password-stdin
18+
19+
- name: GHCR Login
20+
if: (github.event_name != 'pull_request')
21+
uses: docker/login-action@v2
22+
with:
23+
registry: ghcr.io
24+
username: ${{ github.actor }}
25+
password: ${{ secrets.GITHUB_TOKEN }}
26+
2227
- name: Tag and Push images
28+
if: (github.event_name != 'pull_request')
2329
run: |
2430
DOCKER_TAG=$(docker run "${CONTAINER}:latest" --version)
2531
echo "Docker tag is: ${DOCKER_TAG}"

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
formatting:
1212
runs-on: ubuntu-latest
1313
steps:
14-
- uses: actions/checkout@v2
14+
- uses: actions/checkout@v4
1515

1616
- name: Setup black environment
1717
run: conda create --quiet --name black black pyflakes

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM bitnami/minideb:stretch as generator
1+
FROM bitnami/minideb as generator
22
# docker build -t data-container .
33
ENV PATH /opt/conda/bin:${PATH}
44
ENV LANG C.UTF-8

Dockerfile.base

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM bitnami/minideb:stretch as generator
1+
FROM bitnami/minideb as generator
22
# docker build -t data-container .
33
ENV PATH /opt/conda/bin:${PATH}
44
ENV LANG C.UTF-8

cdb/client/__init__.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,26 @@ def get_parser():
4040

4141
description = "actions for cdb"
4242
subparsers = parser.add_subparsers(
43-
help="cdb actions", title="actions", description=description, dest="command",
43+
help="cdb actions",
44+
title="actions",
45+
description=description,
46+
dest="command",
4447
)
4548

4649
# print version and exit
4750
subparsers.add_parser("version", help="show software version")
4851

4952
# Generate a key for the interface
5053
generate = subparsers.add_parser(
51-
"generate", help="generate a template go script for container entrypoint.",
54+
"generate",
55+
help="generate a template go script for container entrypoint.",
5256
)
5357

5458
generate.add_argument(
55-
"path", help="Path to dataset files.", nargs="?", default=".",
59+
"path",
60+
help="Path to dataset files.",
61+
nargs="?",
62+
default=".",
5663
)
5764

5865
# Specify output file, defaults to db.go
@@ -91,14 +98,13 @@ def get_parser():
9198

9299

93100
def main():
94-
"""main entrypoint for cdb
95-
"""
101+
"""main entrypoint for cdb"""
96102

97103
parser = get_parser()
98104

99105
def help(return_code=0):
100-
"""print help, including the software version and active client
101-
and exit with return code.
106+
"""print help, including the software version and active client
107+
and exit with return code.
102108
"""
103109
version = cdb.__version__
104110

cdb/client/generate.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313

1414
def main(args, extra):
15-
1615
# Create a Container database
1716
db = ContainerDatabase(path=args.path)
1817
db.generate(

cdb/functions.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414

1515
def basic(filename):
16-
"""Given a filename, return a dictionary with basic metadata about it
17-
"""
16+
"""Given a filename, return a dictionary with basic metadata about it"""
1817
st = os.stat(filename)
1918
return {"size": st.st_size, "sha256": get_file_hash(filename)}

cdb/logger/message.py

Lines changed: 26 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ def success(self, message):
7878

7979
def useColor(self):
8080
"""useColor will determine if color should be added
81-
to a print. Will check if being run in a terminal, and
82-
if has support for asci
81+
to a print. Will check if being run in a terminal, and
82+
if has support for asci
8383
"""
8484
COLORIZE = get_user_color_preference()
8585
if COLORIZE is not None:
@@ -94,7 +94,7 @@ def useColor(self):
9494

9595
def addColor(self, level, text):
9696
"""addColor to the prompt (usually prefix) if terminal
97-
supports, and specified to do so
97+
supports, and specified to do so
9898
"""
9999
if self.colorize:
100100
if level in self.colors:
@@ -103,7 +103,7 @@ def addColor(self, level, text):
103103

104104
def emitError(self, level):
105105
"""determine if a level should print to
106-
stderr, includes all levels but INFO and QUIET
106+
stderr, includes all levels but INFO and QUIET
107107
"""
108108
if level in [
109109
ABORT,
@@ -126,20 +126,19 @@ def emitOutput(self, level):
126126
return False
127127

128128
def isEnabledFor(self, messageLevel):
129-
"""check if a messageLevel is enabled to emit a level
130-
"""
129+
"""check if a messageLevel is enabled to emit a level"""
131130
if messageLevel <= self.level:
132131
return True
133132
return False
134133

135134
def emit(self, level, message, prefix=None, color=None):
136135
"""emit is the main function to print the message
137-
optionally with a prefix
136+
optionally with a prefix
138137
139-
Arguments:
140-
- level (int) : the level of the message
141-
- message (str) : the message to print
142-
- prefix (str) : a prefix for the message
138+
Arguments:
139+
- level (int) : the level of the message
140+
- message (str) : the message to print
141+
- prefix (str) : a prefix for the message
143142
"""
144143
if color is None:
145144
color = level
@@ -172,15 +171,15 @@ def emit(self, level, message, prefix=None, color=None):
172171

173172
def write(self, stream, message):
174173
"""write will write a message to a stream,
175-
first checking the encoding
174+
first checking the encoding
176175
"""
177176
if isinstance(message, bytes):
178177
message = message.decode("utf-8")
179178
stream.write(message)
180179

181180
def get_logs(self, join_newline=True):
182181
"""'get_logs will return the complete history, joined by newline
183-
(default) or as is.
182+
(default) or as is.
184183
"""
185184
if join_newline:
186185
return "\n".join(self.history)
@@ -198,15 +197,14 @@ def show_progress(
198197
symbol=None,
199198
):
200199
"""create a terminal progress bar, default bar shows for verbose+
201-
202-
Parameters
203-
==========
204-
iteration: current iteration (Int)
205-
total: total iterations (Int)
206-
length: character length of bar (Int)
200+
201+
Parameters
202+
==========
203+
iteration: current iteration (Int)
204+
total: total iterations (Int)
205+
length: character length of bar (Int)
207206
"""
208207
if not self.level == QUIET:
209-
210208
percent = 100 * (iteration / float(total))
211209
progress = int(length * iteration // total)
212210

@@ -289,18 +287,17 @@ def debug(self, message):
289287
self.emit(DEBUG, message, "DEBUG")
290288

291289
def is_quiet(self):
292-
"""is_quiet returns true if the level is under 1
293-
"""
290+
"""is_quiet returns true if the level is under 1"""
294291
if self.level < 1:
295292
return False
296293
return True
297294

298295
# Terminal ------------------------------------------
299296

300297
def table(self, rows, col_width=2):
301-
"""table will print a table of entries. If the rows is
302-
a dictionary, the keys are interpreted as column names. if
303-
not, a numbered list is used.
298+
"""table will print a table of entries. If the rows is
299+
a dictionary, the keys are interpreted as column names. if
300+
not, a numbered list is used.
304301
"""
305302

306303
labels = [str(x) for x in range(1, len(rows) + 1)]
@@ -317,9 +314,9 @@ def table(self, rows, col_width=2):
317314

318315
def get_logging_level():
319316
"""get_logging_level will configure a logging to standard out based on
320-
selected level, which should be in an environment variable called
321-
MESSAGELEVEL. if MESSAGELEVEL is not set, the maximum level
322-
(5) is assumed (all messages).
317+
selected level, which should be in an environment variable called
318+
MESSAGELEVEL. if MESSAGELEVEL is not set, the maximum level
319+
(5) is assumed (all messages).
323320
"""
324321
level = os.environ.get("CDB_MESSAGELEVEL", INFO)
325322

@@ -361,7 +358,7 @@ def get_user_color_preference():
361358

362359
def convert2boolean(arg):
363360
"""convert2boolean is used for environmental variables that must be
364-
returned as boolean
361+
returned as boolean
365362
"""
366363
if not isinstance(arg, bool):
367364
return arg.lower() in ("yes", "true", "t", "1", "y")

cdb/main/__init__.py

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,30 +26,28 @@
2626

2727
class ContainerDatabase:
2828
"""A container database metadata generator will take some input folder
29-
of files, and recursively run a user-provided or cdb-provided function
30-
to extract metadata for each one. If no custom function is provided,
31-
we provide basic metadata about file versions.
29+
of files, and recursively run a user-provided or cdb-provided function
30+
to extract metadata for each one. If no custom function is provided,
31+
we provide basic metadata about file versions.
3232
"""
3333

3434
def __init__(self, path, pattern="*"):
35-
"""extract metadata for some recursive set of data objects
36-
"""
35+
"""extract metadata for some recursive set of data objects"""
3736
self.get_files(path, pattern)
3837
self.path = path
3938
self.pattern = pattern
4039
self.metadata = {}
4140

4241
def get_files(self, path, pattern="*"):
43-
"""return files, given update path and pattern
44-
"""
42+
"""return files, given update path and pattern"""
4543
self.path = path
4644
self.pattern = pattern
4745
return self.files
4846

4947
@property
5048
def files(self):
5149
"""Given a path, check that it exists, and then create an iterator
52-
to go over files.
50+
to go over files.
5351
"""
5452
if self.path in [".", None]:
5553
self.path = os.getcwd()
@@ -59,8 +57,8 @@ def files(self):
5957

6058
def generate(self, output=None, template="db.go", force=False, func=None):
6159
"""Given an output file name and a template, iterate
62-
through files and generate the in-memory database golang file to
63-
compile into a container.
60+
through files and generate the in-memory database golang file to
61+
compile into a container.
6462
"""
6563
bot.debug(f"Loading template {template}")
6664
template = get_template(template)
@@ -91,13 +89,11 @@ def generate(self, output=None, template="db.go", force=False, func=None):
9189
return script
9290

9391
def export_dockerfile(self, name="Dockerfile"):
94-
"""export a Dockerfile that will perform a multistage build to
95-
"""
92+
"""export a Dockerfile that will perform a multistage build to"""
9693
pass
9794

9895
def get_function(self, funcname=None):
99-
"""Given a function name, return it. Exit on error if not found.
100-
"""
96+
"""Given a function name, return it. Exit on error if not found."""
10197
# Default to cdb.functions.basic
10298
funcname = funcname or "basic"
10399

cdb/templates/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616

1717
def get_template(name, load=True):
1818
"""Given the name of a template (a go file to use to generate the dataset
19-
metadata) return the template path if it exists. Otherwise, exit on
20-
error
19+
metadata) return the template path if it exists. Otherwise, exit on
20+
error
2121
"""
2222
# The user can provide a custom template, must have {{ updates }} to include
2323
if not os.path.exists(name):

0 commit comments

Comments
 (0)