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

Config lefthook #25

Merged
merged 22 commits into from
Aug 24, 2024
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
34 changes: 10 additions & 24 deletions crategen/converters/tes_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,37 +25,23 @@ def convert_to_wrroc(self, data: dict) -> dict:
except ValidationError as e:
raise ValueError(f"Invalid TES data: {e.errors()}") from e

# Extract validated data
(
id,
name,
description,
creation_time,
state,
inputs,
outputs,
executors,
resources,
volumes,
logs,
tags,
) = data_tes.dict().values()
end_time = logs[0].end_time
executors = data_tes.executors
end_time = data_tes.logs[0].end_time if data_tes.logs else None

# Convert to WRROC format
wrroc_data = {
Copy link

Choose a reason for hiding this comment

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

issue (code-quality): Inline variable that is immediately returned (inline-immediately-returned-variable)

"@id": id,
"name": name,
"description": description,
"instrument": executors[0]["image"] if executors else None,
"@id": data_tes.id,
"name": data_tes.name,
"description": data_tes.description,
"instrument": executors[0].image if executors else None,
"object": [
{"@id": input["url"], "name": input["path"], "type": input["type"]}
for input in inputs
{"@id": input.url, "name": input.path, "type": input.type}
for input in data_tes.inputs
],
"result": [
{"@id": output["url"], "name": output["path"]} for output in outputs
{"@id": output.url, "name": output.path} for output in data_tes.outputs
],
"startTime": creation_time,
"startTime": data_tes.creation_time,
"endTime": end_time,
}
return wrroc_data
Expand Down
1 change: 1 addition & 0 deletions crategen/converters/wes_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ def convert_from_wrroc(self, data: dict) -> dict:
f"Invalid WRROC data for WES conversion: {e.errors()}"
) from e

# Convert from WRROC to WES format
# Convert from WRROC to WES format
wes_data = {
"run_id": data_wrroc.id,
Expand Down
2 changes: 1 addition & 1 deletion crategen/models/tes_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def validate_content_and_url(cls, values):

if content_is_set:
values["url"] = None
elif not url_is_set:
elif not content_is_set and not url_is_set:
Copy link

Choose a reason for hiding this comment

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

suggestion (code-quality): Remove redundant conditional (remove-redundant-if)

Suggested change
elif not content_is_set and not url_is_set:
elif not url_is_set:

raise ValueError(
"The 'url' attribute is required when the 'content' attribute is empty"
)
Expand Down
5 changes: 4 additions & 1 deletion crategen/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,17 @@ def validate_wrroc(data: dict) -> Union[WRROCProvenance, WRROCWorkflow, WRROCPro
"""
Validate that the input data is a valid WRROC entity and determine which profile it adheres to.


This function attempts to validate the input data against the WRROCProvenance model first.
If that validation fails, it attempts validation against the WRROCWorkflow model.
If that also fails, it finally attempts validation against the WRROCProcess model.

Args:
data (dict): The input data to validate.

Returns:
Union[WRROCProvenance, WRROCWorkflow, WRROCProcess]: The validated WRROC data, indicating the highest profile the data adheres to.


Raises:
ValueError: If the data does not adhere to any of the WRROC profiles.
"""
Expand Down
41 changes: 6 additions & 35 deletions lefthook.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,6 @@
# EXAMPLE USAGE:
#
# Refer for explanation to following link:
# https://github.com/evilmartians/lefthook/blob/master/docs/configuration.md
#
# pre-push:
# commands:
# packages-audit:
# tags: frontend security
# run: yarn audit
# gems-audit:
# tags: backend security
# run: bundle audit
#
# pre-commit:
# parallel: true
# commands:
# eslint:
# glob: "*.{js,ts,jsx,tsx}"
# run: yarn eslint {staged_files}
# rubocop:
# tags: backend style
# glob: "*.rb"
# exclude: '(^|/)(application|routes)\.rb$'
# run: bundle exec rubocop --force-exclusion {all_files}
# govet:
# tags: backend style
# files: git ls-files -m
# glob: "*.go"
# run: go vet {files}
# scripts:
# "hello.js":
# runner: node
# "any.go":
# runner: go run
pre-push:
commands:
ruff:
files: git diff --name-only --diff-filter=d $(git merge-base origin/main HEAD)..HEAD
run: poetry run ruff check {files}
glob: '*.py'
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ exclude = [
"build",
"_build",
"dist",
".env"
".env",
]
indent-width = 4

Expand Down
Loading