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

Code cleanup #42

Merged
merged 31 commits into from
Apr 3, 2019
Merged

Code cleanup #42

merged 31 commits into from
Apr 3, 2019

Conversation

grabear
Copy link
Member

@grabear grabear commented Feb 24, 2019

No description provided.

@sdhutchins
Copy link
Member

It looks clean to me.

@sdhutchins sdhutchins changed the title Grabear update Code cleanup Feb 24, 2019
renv/core.py Outdated Show resolved Hide resolved
renv/core.py Outdated Show resolved Hide resolved
renv/core.py Outdated Show resolved Hide resolved
@santina
Copy link
Collaborator

santina commented Mar 19, 2019

Please be sure to test the code and it'd be all good! :)

@grabear
Copy link
Member Author

grabear commented Mar 19, 2019

😆 I will this afternoon.

@grabear grabear requested a review from santina March 23, 2019 22:53
@grabear
Copy link
Member Author

grabear commented Mar 23, 2019

@santina I've gotten this to work on my system, and I cleaned up the appropriate code. There are still some things that need to be done, but they can be resolved in another major PR.

@sdhutchins
Copy link
Member

Once this gets merged, I'll submit a PR for the debug logging that should be helpful for rebuilding the code base.

renv/utils.py Outdated Show resolved Hide resolved

try:
stdout, stderr = recommended_pkgs.communicate(timeout=15)
except TimeoutExpired:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this the only exception we might hit?

Copy link
Member Author

Choose a reason for hiding this comment

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

There certainly could be others. This particular exception handling block was just the most obvious one. For now I'll create an issue to help resolve this in future PRs.

Copy link
Member Author

Choose a reason for hiding this comment

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

#49

renv/core.py Outdated Show resolved Hide resolved
# Minor Version
minor, error = utils.system_r_call(rcmd_type="major", context=context)

context.R_version = "%s.%s" % (major, minor)
Copy link
Collaborator

Choose a reason for hiding this comment

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

What if we actually got an error in the system_r_call? i.e. stdout is not actually the information we want. We should handle that.

Copy link
Member Author

Choose a reason for hiding this comment

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

Will handle in future updates #49

@@ -24,7 +24,7 @@ classifiers = [
]

[tool.poetry.dependencies]
python = "^3.6"
python = ">=3.4"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is this changed?

Copy link
Member Author

Choose a reason for hiding this comment

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

I want to have more flexibility. In order to get this working on 3.4 I basically just removed F-string formatting and that gave us some backward compatibility. I think allowing 3.4-3.7 would be optimal. I changed this in rinse as well.

Using 2.7 would be good too, but I know 2.7 is going out of style next year. So that's probably not really worth our time.

renv/utils.py Outdated Show resolved Hide resolved
renv/core.py Outdated Show resolved Hide resolved
config_dict["R_VERSION"] = context.R_version
# Package lists
config_dict.update(__DEFAULT_CONFIG__)
pkg_lists = self.format_pkg_list(config_dict)
config_dict.update(pkg_lists)
config_dict.update(user_config)
logging.info(f"Config Dictionary: {config_dict}")
logging.info("Config Dictionary: %s" % config_dict)

# Dump the configuration dictionary to the YAML file in the R environment HOME
yaml.dump(config_dict, f, default_flow_style=False)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could we remove all the commented-out code and instead open an issue and refer to them by issue number, just like what you have with See issue 2487 ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure that was actually copied from python's venv module. But that would probably be a good practice. For now, I'm going to leave it as is. My next PR will be a fairly extensive rework in order to break the functions up, and to handle the OS logic in separate classes (similar to what I just did in rinse; e.g. BaseInstallR, LinuxInstallR, MacInstallR, WindowsInstallR). I envision something like BaseRenvBuilder, LinuxRenvBuilder, MacRenvBuilder, and WIndowsRenvBuilder. These comments will be removed and appropriate issues will be created, if they are needed.

context.env_bin_path = binpath = os.path.join(env_dir, binname)
context.bin_path = binpath
context.env_R_exe = os.path.join(binpath, r_exe)
context.env_R_script = os.path.join(binpath, r_script)
utils.create_directory(context.env_R_libs, self.clear)
logging.info(f"Environment R: {r_env_home}")
logging.info("Environment R: %s" % r_env_home)
return context

def create_configuration(self, context):
Copy link
Collaborator

Choose a reason for hiding this comment

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

This function is huge. Could we break this down into smaller functions? Same go with some of the other functions.

Copy link
Member Author

Choose a reason for hiding this comment

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

See my previous comment.

Copy link
Collaborator

@santina santina left a comment

Choose a reason for hiding this comment

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

Please reply to the comments given. You don't need to address everything, but just need to give a reason if you decide not to take the suggestion.

@grabear
Copy link
Member Author

grabear commented Mar 31, 2019

Please reply to the comments given. You don't need to address everything, but just need to give a reason if you decide not to take the suggestion.

Thank you for the awesome review @santina. You caught some serious bugs that I overlooked. In the next PR, the code will be much easier to follow too! Let me know what you think!

@grabear grabear dismissed santina’s stale review April 3, 2019 20:35

I responded to all of your comments/suggestions. I need to go ahead and merge this so I can continue working on this.

@grabear grabear removed the request for review from BrunoGrandePhD April 3, 2019 20:37
@grabear grabear merged commit 2219a59 into dev-master Apr 3, 2019
@grabear
Copy link
Member Author

grabear commented Apr 3, 2019

I overrode the branch protection settings in order to push this through. Let me know if you have any questions.

@santina
Copy link
Collaborator

santina commented Apr 4, 2019

Sorry for not responding earlier. (go back in time and approve the change)

@sdhutchins sdhutchins deleted the grabear_update branch April 4, 2019 23:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants