Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

15 standardize linting #17

Merged
merged 10 commits into from
Aug 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/mega-linter.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
# MegaLinter GitHub Action configuration file
# More info at https://megalinter.github.io
name: MegaLinter
Expand Down Expand Up @@ -41,9 +42,13 @@ jobs:
# https://megalinter.github.io/configuration/
VALIDATE_ALL_CODEBASE: true
# VALIDATE_ALL_CODEBASE: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} # Validates all source when push on main, else just the git diff with main. Override with true if you always want to lint all sources
PAT: ${{ secrets.PAT }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# ADD YOUR CUSTOM ENV VARIABLES HERE OR DEFINE THEM IN A FILE .mega-linter.yml AT THE ROOT OF YOUR REPOSITORY
DISABLE: COPYPASTE,SPELL # Uncomment to disable copy-paste and spell checks
PYTHON_FLAKE8_ARGUMENTS: --max-line-length=119 # Uncomment to override Flake8 arguments
PYTHON_RUFF_ARGUMENTS: --line-length=119 # Uncomment to override Ruffus arguments


# Upload MegaLinter artifacts
- name: Archive production artifacts
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
# This workflow will install Python dependencies and run tests
name: Python package

Expand Down
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,12 @@ install: venv/bin/pip-sync requirements.txt
requirements.txt: venv/bin/pip-compile requirements.in
. $(ACTIVATE) && pip-compile requirements.in

test: venv install-dev
test: venv install-dev lint
. $(ACTIVATE) && python3 -m pytest --cov --cov-report xml:coverage.xml

lint: venv install-dev
. $(ACTIVATE) && black .

test-partials: venv install-dev
SKIP_PARTIALS=False . $(ACTIVATE) && python3 -m pytest

Expand Down
1 change: 1 addition & 0 deletions dev-requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ benchling-sdk ~= 1.6
botocore ~= 1.31
jinja2 ~= 3.1
quilt3 ~=5.3
black
pytest
pytest-coverage
pytest-watcher
17 changes: 15 additions & 2 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ benchling-api-client==2.0.167
# via benchling-sdk
benchling-sdk==1.7.0
# via -r dev-requirements.in
black==23.7.0
# via -r dev-requirements.in
boto3==1.28.27
# via quilt3
botocore==1.31.27
Expand All @@ -41,6 +43,8 @@ cffi==1.15.1
# via cryptography
charset-normalizer==3.2.0
# via requests
click==8.1.7
# via black
coverage[toml]==7.3.0
# via pytest-cov
cryptography==41.0.3
Expand Down Expand Up @@ -89,15 +93,22 @@ markupsafe==2.1.3
marshmallow==3.20.1
# via dataclasses-json
mypy-extensions==1.0.0
# via typing-inspect
# via
# black
# typing-inspect
ordered-set==4.1.0
# via benchling-sdk
packaging==23.1
# via
# black
# marshmallow
# pytest
pathspec==0.11.2
# via black
platformdirs==3.10.0
# via quilt3
# via
# black
# quilt3
pluggy==1.2.0
# via pytest
pycparser==2.21
Expand Down Expand Up @@ -155,6 +166,7 @@ tenacity==8.2.3
# via quilt3
tomli==2.0.1
# via
# black
# coverage
# pytest
# pytest-watcher
Expand All @@ -165,6 +177,7 @@ typing-extensions==4.7.1
# aws-lambda-powertools
# benchling-api-client
# benchling-sdk
# black
# typing-inspect
typing-inspect==0.9.0
# via dataclasses-json
Expand Down
20 changes: 9 additions & 11 deletions lambdas/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,7 @@ def __init__(self, tenant, id, arn):

def get_task(self, entry_id):
self.task = self.benchling.tasks.wait_for_task(
self.benchling.exports.export(
benchling_models.ExportItemRequest(id=entry_id) # type: ignore
).task_id
self.benchling.exports.export(benchling_models.ExportItemRequest(id=entry_id)).task_id # type: ignore
)
if self.task.status != benchling_models.AsyncTaskStatus.SUCCEEDED:
raise Exception(f"Notes export failed: {self.task!r}")
Expand Down Expand Up @@ -88,10 +86,10 @@ class BenchlingEntry:
]
)

FLD = {
"URI": "Quilt+ URI",
"CAT": "Quilt Catalog URL",
"REV": "Quilt Revise URL",
FIELDS = {
"QUILT_URI": "Quilt+ URI",
"CATALOG_URL": "Quilt Catalog URL",
"REVISE_URL": "Quilt Revise URL",
}

ENTRY_FMT = """
Expand Down Expand Up @@ -189,11 +187,11 @@ def push_package(self, tmpdir_path):

def field_values(self):
values = {
"URI": f"quilt+s3://{self.DST_BUCKET}#package={self.pkg_name}",
"CAT": f"{self.QUILT_PREFIX}/{self.pkg_name}",
"REV": f"{self.QUILT_PREFIX}/{self.pkg_name}?{self.REVISE}",
"QUILT_URI": f"quilt+s3://{self.DST_BUCKET}#package={self.pkg_name}",
"CATALOG_URL": f"{self.QUILT_PREFIX}/{self.pkg_name}",
"REVISE_URL": f"{self.QUILT_PREFIX}/{self.pkg_name}?{self.REVISE}",
}
return {f: values.get(k) for k, f in self.FLD.items()}
return {f: values.get(k) for k, f in self.FIELDS.items()}

def update_benchling_notebook(self) -> bool:
values = self.field_values()
Expand Down
Empty file modified layer/deploy.sh
100644 → 100755
Empty file.
14 changes: 4 additions & 10 deletions make.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ def make_lambda_environment(**kwargs):
def get_metadata():
"""build-time metadata for inclusion in template"""
return {
"git_revision": subprocess.run(
("git", "rev-parse", "HEAD"), capture_output=True, text=True
).stdout.rstrip(),
"git_revision": subprocess.run(("git", "rev-parse", "HEAD"), capture_output=True, text=True).stdout.rstrip(),
"git_repository": subprocess.run(
("git", "rev-parse", "--show-toplevel"), capture_output=True, text=True
).stdout.rstrip(),
Expand All @@ -59,9 +57,7 @@ def make_layer(cft: troposphere.Template):


def make_template(*, metadata: dict) -> troposphere.Template:
description = (
"Automatically create a dedicated Quilt package for every Benchling notebook"
)
description = "Automatically create a dedicated Quilt package for every Benchling notebook"
cft = troposphere.Template(Description=description)
troposphere.Output(
"TemplateBuildMetadata",
Expand All @@ -76,17 +72,15 @@ def make_template(*, metadata: dict) -> troposphere.Template:
Type="String",
AllowedPattern=r"^aws\.partner(/[\.\-_A-Za-z0-9]+){2,}$",
Description=(
"Name of event bus where Benchling events are emitted, "
+ "e.g aws.partner/benchling.com/tenant/app-name"
"Name of event bus where Benchling events are emitted, " + "e.g aws.partner/benchling.com/tenant/app-name"
),
)
benchling_tenant = troposphere.Parameter(
"BenchlingTenant",
template=cft,
Type="String",
AllowedPattern=r"^[^/]+$",
Description="Benchling tenant name, i.e. $BenchlingTenant in "
+ "https://$BenchlingTenant.benchling.com",
Description="Benchling tenant name, i.e. $BenchlingTenant in " + "https://$BenchlingTenant.benchling.com",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not?

Suggested change
Description="Benchling tenant name, i.e. $BenchlingTenant in " + "https://$BenchlingTenant.benchling.com",
Description="Benchling tenant name, i.e. $BenchlingTenant in https://$BenchlingTenant.benchling.com",

)
benchling_client_id = troposphere.Parameter(
"BenchlingClientId",
Expand Down
5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[tool.black]
line-length = 119
target-version = ['py37']
include = '\.pyi?$'
# 'extend-exclude' excludes files or directories in addition to the defaults