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

Fix "deps check all" command #388

Merged
merged 7 commits into from
Jan 18, 2024
Merged

Fix "deps check all" command #388

merged 7 commits into from
Jan 18, 2024

Conversation

popenta
Copy link
Contributor

@popenta popenta commented Jan 5, 2024

No description provided.

@popenta popenta self-assigned this Jan 5, 2024
@@ -338,7 +321,7 @@ def _install_sc_meta(self):
tag = config.get_dependency_tag("sc-meta")
args = ["cargo", "install", "multiversx-sc-meta", "--locked"]

if tag != "latest":
if tag != "":
Copy link
Contributor

Choose a reason for hiding this comment

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

Can be if not tag (also below).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Replaced with if tag:


for dependency in all_dependencies:
tag_to_check: str = config.get_dependency_tag(dependency.key)
is_installed = check_module_is_installed(dependency, tag_to_check)
Copy link
Contributor

Choose a reason for hiding this comment

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

This does not handle rust the complete way, as done below.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed


raise errors.DependencyMissing(name, tag_to_check)
def _get_actual_installed_rust_version() -> str:
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we have it directly in Rust dependency module - modules.py, by overriding is_installed()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved it in the Rust module.


raise errors.DependencyMissing(name, tag_to_check)
def _get_actual_installed_rust_version() -> str:
args = ["rustup", "default"]
Copy link
Contributor

Choose a reason for hiding this comment

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

Will throw if rust is not installed beforehand, and the error is not caught (sorry if I'm mistaken).

Perhaps do a try / catch here and return empty string if missing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It didn't trow any error as it was called only if is_installed was True.

def _get_actual_installed_rust_version() -> str:
args = ["rustup", "default"]
output = run_process(args, dump_to_stdout=False)
return output.rstrip("\n")
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps use strip() directly, in case other whitespace might occur in the future?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now using strip().

if len(missing_dependencies):
raise errors.DependenciesMissing(missing_dependencies)
return
if name == "rust":
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice for having the check done in this new, better way.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is now refactored.

module = dependencies.get_module_by_key(name)
tag_to_check: str = config.get_dependency_tag(module.key)

if name == "all":
Copy link
Contributor

Choose a reason for hiding this comment

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

After re-thinking about this, maybe we can drop check all and install all? On the long run, maybe it's better (less issues, less corner cases) if we do.

Let's double check with @ovidiuolteanu and @ccorcoveanu. I feel deps install all is quite exotic.

@popenta popenta changed the base branch from main to feat/next January 8, 2024 15:55

if tag in actual_version_installed:
logger.info(f"[{self.key} {tag}] is installed.")
elif "Command 'rustup' not found" in actual_version_installed:
Copy link
Contributor

Choose a reason for hiding this comment

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

The error message might look differently on MacOS. E.g.

multiversx@papple ~ % rustupfoobar
zsh: command not found: rustupfoobar
multiversx@papple ~ % 

Thus, we can check for "not found" in actual_version_installed perhaps?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed. Now the elif statement is as above.

tag_to_check: str = config.get_dependency_tag(module.key)

is_installed = check_module_is_installed(module, tag_to_check)
if is_installed and name != "rust":
Copy link
Contributor

Choose a reason for hiding this comment

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

For Rust, we don't display this log info? Or without this if the message will be duplicated by the one from modules.py? I think better to have it duplicated on the CLI than to have this custom if here (e.g. in the future we will forget its reason).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Without the if statement the message will be duplicated by the one in modules.py. Why I added it it's because if you have a different Rust version other than the recommended one, you'll see a warning that the versions don't match but the log will show that the correct version is installed since it takes the tag from the config.
A problem that could occur with the other dependencies as well, now that I think about it, but is less common.

andreibancioiu
andreibancioiu previously approved these changes Jan 9, 2024
@ssd04 ssd04 self-requested a review January 10, 2024 07:48
Comment on lines +38 to +39

if name == "all":
Copy link
Contributor

Choose a reason for hiding this comment

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

cargo does not seem to be loaded correctly when trying to install all deps

Copy link
Contributor

Choose a reason for hiding this comment

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

tested and it seems to work now 👍

@popenta popenta merged commit 604774c into feat/next Jan 18, 2024
11 checks passed
@popenta popenta deleted the fix-deps-all branch January 18, 2024 11:18
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.

3 participants