-
Notifications
You must be signed in to change notification settings - Fork 2
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
Add setup for the tool usage #59
Conversation
Co-authored-by: yoav-el-certora <[email protected]>
Co-authored-by: yoav-el-certora <[email protected]>
Co-authored-by: yoav-el-certora <[email protected]>
Co-authored-by: yoav-el-certora <[email protected]>
Co-authored-by: yoav-el-certora <[email protected]>
Co-authored-by: yoav-el-certora <[email protected]>
…nto niv/CERT-7888-Add-Setup
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor naming changes to avoid future confusions.
I think using json5 is unnecessary since you are using it because of the templates, but:
- You shouldn't open these template files, just copy them for the user (correct me if I'm wrong).
- The user has to configure these templates either and they will most likely remove the comments because the files are formatted as json and their IDE will tell them there are errors.
This introduces another third party dependency which we don't need.
Repo organization looks great. Setup tool implementation is clean.
@@ -3,7 +3,7 @@ | |||
from typing import Optional | |||
from pydantic import BaseModel, Field | |||
from pathlib import Path | |||
import json | |||
import json5 as json |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please change that to simply import json5
. I'm afraid that down the line it will get confusing because these 2 packages do act a little bit differently in certain things (as you saw).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The difference between them is agnostic, if it will cause any issue in the future we can change it. for now, i prefer it to be called json instead of a variable with number name just for apperance.
@@ -1,6 +1,6 @@ | |||
import requests | |||
from dataclasses import dataclass | |||
import json | |||
import json5 as json |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same
@@ -1,9 +1,9 @@ | |||
from abc import ABC | |||
from datetime import datetime | |||
import json | |||
import json5 as json |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
@@ -1,5 +1,6 @@ | |||
import argparse | |||
import json | |||
from json import JSONDecodeError | |||
import json5 as json |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
import shutil | ||
import argparse | ||
from pathlib import Path | ||
import Quorum.utils.pretty_printer as pp |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Blank line above please :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
for file_name in template_files: | ||
src = templates_dir / file_name | ||
dest = target_dir / '.env' if file_name == '.env.example' else target_dir / file_name | ||
|
||
if dest.exists(): | ||
pp.pretty_print(f"File exists: {dest}. Skipping.", pp.Colors.WARNING) | ||
continue | ||
|
||
shutil.copy(src, dest) | ||
pp.pretty_print(f"Copied {file_name} to {dest}", pp.Colors.SUCCESS) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked and if .env
is in a subdirectory it won't be found automatically so you can rename .env.example
to .env
without worrying. With that you can just use shutil.copytree
instead of the whole for loop but that means everything will be overridden, unlike how you skip existing files. Which I actually think can be better because if a user messes his directory or one of the files he can easily just run this tool again.
You have the option, whatever you prefer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer the current state, and also i would suggest to not upload a .env to the repo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I already told you that I think changing the expected file instead of changing the code is principally wrong. Yes even for the smallest of differences like ", especially when the fix involves adding 3 words.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand your point and yet if the output is improved i am not seeing any issue with modify the test for the better output.
@@ -5,7 +5,7 @@ | |||
from Quorum.utils.chain_enum import Chain | |||
from Quorum.apis.price_feeds import PriceFeedData, ChainLinkAPI, ChronicleAPI, CoinGeckoAPI | |||
|
|||
import json | |||
import json5 as json |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
@@ -4,7 +4,7 @@ | |||
|
|||
from Quorum.apis.block_explorers.source_code import SourceCode | |||
|
|||
import json | |||
import json5 as json |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
@@ -1,6 +1,6 @@ | |||
import json | |||
import json5 as json |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
I honestly don't see any difference in terms of using json5 over json. as long as it dosent introduce any issues its preferred to be used just in case the user will leave comments in the templates instead of crashing the tool. and most users use sublime text and not a real ide for just general knowledge. |
template_files = [f.name for f in templates_dir.iterdir() if f.is_file()] | ||
|
||
for file_name in template_files: | ||
src = templates_dir / file_name | ||
dest = target_dir / '.env' if file_name == '.env.example' else target_dir / file_name | ||
|
||
if dest.exists(): | ||
pp.pretty_print(f"File exists: {dest}. Skipping.", pp.Colors.WARNING) | ||
continue | ||
|
||
shutil.copy(src, dest) | ||
pp.pretty_print(f"Copied {file_name} to {dest}", pp.Colors.SUCCESS) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
template_files = [f.name for f in templates_dir.iterdir() if f.is_file()] | |
for file_name in template_files: | |
src = templates_dir / file_name | |
dest = target_dir / '.env' if file_name == '.env.example' else target_dir / file_name | |
if dest.exists(): | |
pp.pretty_print(f"File exists: {dest}. Skipping.", pp.Colors.WARNING) | |
continue | |
shutil.copy(src, dest) | |
pp.pretty_print(f"Copied {file_name} to {dest}", pp.Colors.SUCCESS) | |
template_files = [f for f in templates_dir.iterdir() if f.is_file()] | |
for file in template_files: | |
dest = target_dir / '.env' if file.name == '.env.example' else target_dir / file.name | |
if dest.exists(): | |
pp.pretty_print(f"File exists: {dest}. Skipping.", pp.Colors.WARNING) | |
continue | |
shutil.copy(file, dest) | |
pp.pretty_print(f"Copied {file.name} to {dest}", pp.Colors.SUCCESS) |
Last one since functionality changed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure its going to work for the .env check. so ill keep it for now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will work as you iterate on absolute files
https://certora.atlassian.net/browse/CERT-7888
Title: Refactor Configuration Management and Introduce Setup Command
Description:
This Pull Request introduces key enhancements to the Quorum project, focusing on improving configuration management, streamlining the setup process, and enhancing the overall codebase structure. The changes aim to provide a more efficient onboarding experience, ensure better code organization, and maintain high performance standards.
Key Changes:
Configuration Management:
Quorum/config.py
toQuorum/utils/config.py
to better reflect its utility purpose.json
module withjson5
across multiple files to allow for more flexible JSON parsing (e.g., comments, trailing commas).JSONDecodeError
andValueError
.ground_truth.json
andexecution.json
within the configuration script.FileNotFoundError
if essential configuration files are missing.Setup Command Introduction:
SetupQuorum
:SetupQuorum
as a new CLI entry point insetup.py
, enabling users to initialize their Quorum environment effortlessly.setup_quorum.py
:ground_truth.json
,execution.json
,.env.example
,Readme.md
) to the specified working directory.CLI Enhancements:
entry_points
:check_proposal.py
,create_report.py
,ipfs_validator.py
) to theQuorum/entry_points/
directory for better organization.console_scripts
insetup.py
to reflect the new locations of the entry point scripts.CI Pipeline Adjustments:
CI.yml
:QUORUM_PATH
from.
toQuorum/tests
to align with the new project structure.regression.json
in the regression tests toQuorum/tests/regression.json
.Dependency Updates:
json5
torequirements.txt
:json5
as a dependency to support the new JSON parsing requirements.Documentation Updates:
README.md
:SetupQuorum
command.Template Management:
templates
Directory:Quorum/templates/
directory containing template configuration files (ground_truth.json
,execution.json
,.env.example
,Readme.md
) to standardize setup procedures.