From 5a4690d25d18aaa1255011453767f93fca4b013d Mon Sep 17 00:00:00 2001 From: "omar.elrifai" Date: Tue, 8 Feb 2022 11:36:33 +0100 Subject: [PATCH] manually lint code --- clinica/engine/prov_model.py | 9 ++++----- clinica/engine/prov_utils.py | 4 ++-- clinica/engine/provenance.py | 13 +++++++------ clinica/pipelines/engine.py | 1 + 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/clinica/engine/prov_model.py b/clinica/engine/prov_model.py index 457ac725bb..1bc1e30bc2 100644 --- a/clinica/engine/prov_model.py +++ b/clinica/engine/prov_model.py @@ -1,13 +1,12 @@ +from abc import ABC, abstractmethod +from typing import List, Union from xml.dom.minidom import Element -from attr import define, field + import attr import cattr -from typing import Union, List -from abc import ABC, abstractmethod - +from attr import define, field from matplotlib.style import context - # Define PROV abstract concepts diff --git a/clinica/engine/prov_utils.py b/clinica/engine/prov_utils.py index 332c14fdab..fde16cea30 100644 --- a/clinica/engine/prov_utils.py +++ b/clinica/engine/prov_utils.py @@ -1,5 +1,5 @@ -from typing import Optional, List from pathlib import Path +from typing import List, Optional from .prov_model import * @@ -12,8 +12,8 @@ def get_files_list(self, pipeline_fullname: str, dict_field="input_to") -> List[ return list of 'Path's to the files used in the pipeline """ - from clinica.utils.inputs import clinica_file_reader import clinica.utils.input_files as cif + from clinica.utils.inputs import clinica_file_reader dict_field_options = ["input_to", "output_from"] if dict_field not in dict_field_options: diff --git a/clinica/engine/provenance.py b/clinica/engine/provenance.py index b5705ad119..3bb70932e4 100644 --- a/clinica/engine/provenance.py +++ b/clinica/engine/provenance.py @@ -1,6 +1,5 @@ import functools from os import read - from pathlib import Path from typing import List @@ -56,7 +55,7 @@ def get_history_record(paths_files: List[Path]) -> ProvRecord: a ProvRecord for the associated files in path_files """ - from .prov_utils import read_prov_jsonld, get_path_prov + from .prov_utils import get_path_prov, read_prov_jsonld prov_record = ProvRecord({}, []) @@ -127,13 +126,14 @@ def extend_prov(prov_main: dict, prov_new: dict) -> dict: def get_agent() -> ProvAgent: - import clinica + from clinica import __name__, __version__ + from .prov_utils import generate_agent_id new_agent = ProvAgent(uid=generate_agent_id()) - new_agent.attributes["version"] = clinica.__version__ - new_agent.attributes["label"] = clinica.__name__ + new_agent.attributes["version"] = __version__ + new_agent.attributes["label"] = __name__ return new_agent @@ -144,13 +144,14 @@ def get_activity(self, agent: Identifier, entities: List[ProvEntity]) -> ProvAct ProvActivity from related entities and associated agent """ import sys + from .prov_utils import generate_activity_id new_activity = ProvActivity(uid=generate_activity_id(self.fullname)) new_activity.attributes["parameters"] = self.parameters new_activity.attributes["label"] = self.fullname - new_activity.attributes["command"] = (sys.argv[1:],) + new_activity.attributes["command"] = sys.argv[1:] new_activity.attributes["used"] = [str(x.uid) for x in entities] new_activity.attributes["wasAssociatedWith"] = str(agent.uid) diff --git a/clinica/pipelines/engine.py b/clinica/pipelines/engine.py index 68e3562f70..da7d35fae8 100644 --- a/clinica/pipelines/engine.py +++ b/clinica/pipelines/engine.py @@ -7,6 +7,7 @@ import click from nipype.pipeline.engine import Workflow + import clinica.engine.provenance as prov