From 39422f6d734d6871a6b9914b1a148f6e29f8e432 Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Sun, 23 Jul 2023 17:09:21 -0400 Subject: [PATCH 1/3] Make codespell happy again: afile -> f, ignore typoed line in CHANGELOG --- .codespellrc | 1 + src/nidm/experiment/Query.py | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.codespellrc b/.codespellrc index 086c01f6..d348ceea 100644 --- a/.codespellrc +++ b/.codespellrc @@ -1,5 +1,6 @@ [codespell] skip = .git,*.pdf,*.svg,*.js,*.ttl +ignore-regex = Splitted.*is not a word # Commun - abbreviation in publication venue # nd - some css within .rst # Groth - name diff --git a/src/nidm/experiment/Query.py b/src/nidm/experiment/Query.py index de50af7e..87f9777a 100644 --- a/src/nidm/experiment/Query.py +++ b/src/nidm/experiment/Query.py @@ -1356,11 +1356,11 @@ def OpenGraph(file): BLOCKSIZE = 65536 hasher = hashlib.md5() - with open(file, "rb") as afile: - buf = afile.read(BLOCKSIZE) + with open(file, "rb") as f: + buf = f.read(BLOCKSIZE) while len(buf) > 0: hasher.update(buf) - buf = afile.read(BLOCKSIZE) + buf = f.read(BLOCKSIZE) digest = hasher.hexdigest() pickle_file = f"{tempfile.gettempdir()}/rdf_graph.{digest}.pickle" From 3a4f81b655a4976b28ce0d8a9aa3e25d9bf658c2 Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Mon, 24 Jul 2023 12:33:19 -0400 Subject: [PATCH 2/3] Add [devel] install_extra and brief description for setup to README.md --- README.rst | 20 ++++++++++++++++++++ setup.cfg | 3 +++ 2 files changed, 23 insertions(+) diff --git a/README.rst b/README.rst index e43d2d5a..a0a2142e 100644 --- a/README.rst +++ b/README.rst @@ -42,6 +42,26 @@ your user space and use the pull request GitHub feature to submit code for review. Please provide a reasonably detailed description of what was changed and why in the pull request. +To establish development environment, we recommend to install the +clone of this repository in development mode with development tools +installed via + +.. code:: bash + + $ pip install -e .[devel] + +We also recommend using +`pre-commit `_ for ensuring +that your contributions would conform our conventions for code quality +etc. You can enable ``pre-commit`` by running once in your clone + +.. code:: bash + + $ pre-commit install + +which would then ensure that all commits would be subject to `black +`_ code reformatting etc. + Reporting Issues or Problems ============================ If you encounter a bug, you can directly report it in the issues section. diff --git a/setup.cfg b/setup.cfg index 94801f75..7002640f 100644 --- a/setup.cfg +++ b/setup.cfg @@ -56,6 +56,9 @@ install_requires = tools = matplotlib seaborn +devel = + pytest + pre-commit [options.packages.find] where = src From fff2298187e08e09d96cadcafc2e7f029569b938 Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Mon, 24 Jul 2023 12:35:51 -0400 Subject: [PATCH 3/3] [DATALAD RUNCMD] Force a run of pre-commit to run black to fix formatting === Do not change lines below === { "chain": [], "cmd": "pre-commit run -a || :", "exit": 0, "extra_inputs": [], "inputs": [], "outputs": [], "pwd": "." } ^^^ Do not change lines above ^^^ --- src/nidm/experiment/Project.py | 1 - src/nidm/experiment/tools/bidsmri2nidm.py | 26 ++++++++++++++--------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/nidm/experiment/Project.py b/src/nidm/experiment/Project.py index c2b7f929..fdac69f8 100644 --- a/src/nidm/experiment/Project.py +++ b/src/nidm/experiment/Project.py @@ -130,7 +130,6 @@ def add_dataelements(self, dataelement): # dataelement.add_attributes({pm.QualifiedName(pm.Namespace("dct", Constants.DCT), 'isPartOf'): self}) return True - def __str__(self): return "NIDM-Experiment Project Class" diff --git a/src/nidm/experiment/tools/bidsmri2nidm.py b/src/nidm/experiment/tools/bidsmri2nidm.py index b0de02d4..49a0a6c5 100755 --- a/src/nidm/experiment/tools/bidsmri2nidm.py +++ b/src/nidm/experiment/tools/bidsmri2nidm.py @@ -28,12 +28,12 @@ Project, Session, ) +from nidm.experiment.Core import getUUID from nidm.experiment.Utils import ( add_attributes_with_cde, addGitAnnexSources, map_variables_to_terms, ) -from nidm.experiment.Core import getUUID def getRelPathToBIDS(filepath, bids_root): @@ -231,7 +231,13 @@ def addbidsignore(directory, filename_to_add): def addimagingsessions( - bids_layout, subject_id, session, participant, directory, collection, img_session=None + bids_layout, + subject_id, + session, + participant, + directory, + collection, + img_session=None, ): """ This function adds imaging acquistions to the NIDM file and deals with BIDS structures potentially having @@ -992,15 +998,15 @@ def bidsmri2project(directory, args): provgraph = project.getGraph() collection = provgraph.collection(Constants.NIIRI[getUUID()]) # 7/22/23 add type as bids:Dataset - collection.add_attributes({PROV_TYPE: QualifiedName( - Namespace("bids", Constants.BIDS), "Dataset" - )}) + collection.add_attributes( + {PROV_TYPE: QualifiedName(Namespace("bids", Constants.BIDS), "Dataset")} + ) # if there are git annex sources then add them num_sources = addGitAnnexSources(obj=project.get_uuid(), bids_root=directory) # else just add the local path to the dataset - #if num_sources == 0: - # 7/22/23 - modified to add location attribute to collection of acquisition objects + # if num_sources == 0: + # 7/22/23 - modified to add location attribute to collection of acquisition objects # collection.add_attributes({Constants.PROV["Location"]: "file:/" + directory}) # add various attributes if they exist in BIDS dataset description file @@ -1163,7 +1169,7 @@ def bidsmri2project(directory, args): acq_entity = AssessmentObject(acquisition=acq) # Modified 7/22/23 to add acq_entity to collection - provgraph.hadMember(collection,acq_entity) + provgraph.hadMember(collection, acq_entity) # create participant dictionary indexed by subjid to get agen UUIDs for later use participant[subjid] = {} @@ -1490,7 +1496,7 @@ def bidsmri2project(directory, args): ) # else just add the local path to the dataset # 7/22/23 commented out to not add local source if no gitAnnex source found - #if num_sources == 0: + # if num_sources == 0: # acq_entity.add_attributes( # {Constants.PROV["Location"]: "file:/" + tsv_file} # ) @@ -1527,7 +1533,7 @@ def bidsmri2project(directory, args): ) # else just add the local path to the dataset # 7/22/23 commented out so local source file isn't stored if no gitAnnex sources - #if num_sources == 0: + # if num_sources == 0: # json_entity.add_attributes( # {Constants.PROV["Location"]: "file:/" + data_dict} # )