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

report on repo #56

Merged
merged 13 commits into from
Apr 17, 2024
Merged

Conversation

abhicodes369
Copy link
Contributor

@abhicodes369 abhicodes369 commented Mar 8, 2024

Describe the changes you have made in this PR

created a report on the repository like the name of the contributor and how many are being tested
A clear and concise description of what you want to happen
a simple HTML is being generated if you execute this script

Link this PR to an issue [optional]

Fixes #47

Checklist

  • Self-review of changed code
  • Added automated tests where applicable
  • Update Docs & Guides

Copy link
Contributor

Choose a reason for hiding this comment

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

This should go into the website folder. Another PR is also creating files there.

Copy link
Contributor

Choose a reason for hiding this comment

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

What is the idea behind setting these variables? You should be able to get the repository location from the location of the file, e.g. using the __file__ variable.

repostatus.py Outdated
Copy link
Contributor

Choose a reason for hiding this comment

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

This should move somewhere else. Probably utilities/repository or something.

repostatus.py Outdated
import json

# Load environment variables
load_dotenv(r'C:\Users\home\tf2.4\TF2.4_IVIM-MRI_CodeCollection\local.env')
Copy link
Contributor

Choose a reason for hiding this comment

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

We should be able to get around hard coding paths. This won't work for me, for example.

repostatus.py Outdated
load_dotenv(r'C:\Users\home\tf2.4\TF2.4_IVIM-MRI_CodeCollection\local.env')

# Read the CSV file
csv_file_path = os.getenv('CODE_CONTRIBUTIONS_FILE')
Copy link
Contributor

Choose a reason for hiding this comment

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

Looking through the code I realize that your table is missing a column, wrapped. In the issue thread I mentioned parsing the files in the folders which isn't being done here, and that's what is missing. It should parse the wrapper folder to find which algorithms are wrapped.

And there I also mentioned double checking the code contributions against what is in the source folder.

So the source code folder and code contribution file should match. If not it would be nice to note that. That should be a superset of the wrapped code list. And that should be a superset of the tested code list. If anything doesn't match that logic then we should note it in the html or printing a message.

repostatus.py Outdated
@@ -0,0 +1,37 @@
import os
import pandas as pd
Copy link
Contributor

Choose a reason for hiding this comment

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

Pandas caused the test failure. It should be in the requirements.

@abhicodes369
Copy link
Contributor Author

I apologize I accidentally deleted the git ignore file can I create a new branch

@etpeterson
Copy link
Contributor

I apologize I accidentally deleted the git ignore file can I create a new branch

Sure, start over or just add it back on this branch, either one.

Copy link
Contributor

@etpeterson etpeterson left a comment

Choose a reason for hiding this comment

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

Sorry, I'm rethinking this a little. Some of these that you're trying to find could be useful in the csv file anyway, so perhaps just adding them could simplify the script a lot. Then it could be a simpler process to generate the html from the csv.

import json

# directory of the current script
script_dir = os.path.dirname(os.path.abspath(__file__))
Copy link
Contributor

Choose a reason for hiding this comment

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

I think by the convention you're been following, this should be SCRIPT_DIR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Would it be problematic to add a column called 'algorithms' to the data frame? it would be easily understandable. Is it a bad idea?

Copy link
Contributor

Choose a reason for hiding this comment

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

What would that add? The algorithms from the json are the ones running the automated testing. That's beyond the scope of the csv file. Is there some other algorithm you want to add?

print(f"Warning: Subfolder '{subfolder}' does not exist in the source folder.")

# Add column 'Tested' to the DataFrame if it starts with that of subfolder
df['Tested'] = df.apply(lambda row: 'Yes' if any(algorithm.startswith(row['subfolder'].split('_')[0]) for algorithm in all_algorithms) else 'No', axis=1)
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm just looking at this logic and it seems like it's just matching everything before the first _. That's not specific because that's usually the author's initials and they can have several algorithms.

Looking at it a little more, this could become fancier, but maybe we actually want this column in our csv file. So another approach would be to just manually go through and find the matches and add a "Wrapped" column to the csv file that contains what you'd see in the algorithms.json.

Then that would reduce what is needed in here to just having a sanity check that the wrapped folders match the csv. And it would make checking for tested much easier because it would be a simple string match.

How does that sound?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

do i need to manually update the code_contribution_csv file or write a script to read algorithms from algorithms.json and write 'wrapped' in csv file and automatically update whenever there is change in algorithms. json file

Copy link
Contributor

Choose a reason for hiding this comment

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

Add the column manually. That column is not the same as what's in algorithm.json. That column would be the wrapped name, so if an algorithm is wrapped it should have an entry there. The algorithm.json is what is being tested. In theory everything wrapped should be tested but it does need to be added and confirmed it doesn't fail. So they're not the same thing.


# Parse files in the WRAPPED_FOLDER
wrapped_algorithms = []
for root, dirs, files in os.walk(WRAPPED_FOLDER):
Copy link
Contributor

Choose a reason for hiding this comment

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

This could just be added to the csv, see comment above.

wrapped_algorithms.append(algorithm)

# Add a column 'Wrapped' to the DataFrame
df['Wrapped'] = df.apply(lambda row: 'Yes' if any(algorithm.startswith(row['subfolder'].split('_')[0]) for algorithm in wrapped_algorithms) else 'No', axis=1)
Copy link
Contributor

Choose a reason for hiding this comment

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

This as well, see above.

html_string = df_selected.to_html(index=False)

# Save the HTML to a file
with open(os.path.join(REPO_DIR, 'combined_report.html'), 'w') as f:
Copy link
Contributor

Choose a reason for hiding this comment

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

I think os.path.join(REPO_DIR, website, 'combined_report.html')

@etpeterson
Copy link
Contributor

This is looking good, I think you're almost there. After these small changes I'll send it around to the contributors for a final sanity check.

@etpeterson
Copy link
Contributor

Just checking on this, are these changes still in the works?

@abhicodes369
Copy link
Contributor Author

image
it looks like this.
Are there any modifications required?

@etpeterson
Copy link
Contributor

image
it looks like this.
Are there any modifications required?

I had 3 comments that look like they haven't been addressed yet. Small but useful like choosing empty rather than no.

@abhicodes369
Copy link
Contributor Author

i am sorry but i couldnt find these comments could you please give the link to comments that state necessary changes

Copy link
Contributor

@etpeterson etpeterson left a comment

Choose a reason for hiding this comment

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

Sorry! It was my fault, I didn't finalize the review.

IVIM,Fitting,Segmented NLLS fitting,Specifically tailored algorithm for NLLS segmented fitting,OJ_GU,TF2.4_IVIM-MRI_CodeCollection/src/original/OJ_GU/,Oscar Jalnefjord,University of Gothenburg,seg,https://doi.org/10.1007/s10334-018-0697-5,tbd,
IVIM,Fitting,Linear fit,Linear fit for D and D* and f. Intended to be extremely fast but not always accurate,ETP_SRI,TF2.4_IVIM-MRI_CodeCollection/src/original/ETP_SRI/LinearFitting.py,Eric Peterson,SRI International,,,tbd,
Technique,Category,Subcategory,notes,subfolder,Link to source code,Authors,Institution,function/module,DOI,Tester,test status,wrapped
IVIM,Fitting,LSQ fitting,,OGC_AmsterdamUMC,TF2.4_IVIM-MRI_CodeCollection/src/original/OGC_AmsterdamUMC/,Oliver Gurney-Champion,Amsterdam UMC,fit_least_squares/fit_least_squares_array,,tbd,,no
Copy link
Contributor

Choose a reason for hiding this comment

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

Rather than no probably just blank is easier to handle later on.

@@ -5,142 +5,142 @@
<th>Subfolder</th>
<th>Contributors</th>
<th>Tested</th>
<th>Wrapped</th>
<th>wrapped</th>
Copy link
Contributor

Choose a reason for hiding this comment

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

Caps here

website/combined_report.html Show resolved Hide resolved
@etpeterson
Copy link
Contributor

i am sorry but i couldnt find these comments could you please give the link to comments that state necessary changes

Apologies, I didn't finish the review so my comments didn't show for you.

@etpeterson
Copy link
Contributor

Looks like a merge conflict in requirements.txt.

Copy link
Contributor

@etpeterson etpeterson left a comment

Choose a reason for hiding this comment

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

Looks good, just those changes then I'll run it locally as a final test.

utilities/repostatus.py Show resolved Hide resolved
@etpeterson etpeterson merged commit a6b225d into OSIPI:main Apr 17, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Automatically report on repository status
2 participants