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

Check if the environment is up to date #255

Open
github-actions bot opened this issue Oct 11, 2024 · 0 comments
Open

Check if the environment is up to date #255

github-actions bot opened this issue Oct 11, 2024 · 0 comments
Labels

Comments

@github-actions
Copy link

// TODO: Check if the environment is up to date

using CSnakes.Runtime.Locators;
using Microsoft.Extensions.Logging;

namespace CSnakes.Runtime.EnvironmentManagement;
#pragma warning disable CS9113 // Parameter is unread. There for future use.
internal class CondaEnvironmentManagement(ILogger logger, string name, bool ensureExists, CondaLocator conda, string? environmentSpecPath) : IEnvironmentManagement
#pragma warning restore CS9113 // Parameter is unread.
{
    ILogger IEnvironmentManagement.Logger => logger;

    public void EnsureEnvironment(PythonLocationMetadata pythonLocation)
    {
        if (!ensureExists)
            return;


        var fullPath = Path.GetFullPath(GetPath());
        if (!Directory.Exists(fullPath))
        {
            logger.LogError("Cannot find conda environment at {fullPath}.", fullPath);
            // TODO: Automate the creation of the conda environments. 
            //var result = conda.ExecuteCondaShellCommand($"env create -n {name} -f {environmentSpecPath}");
            //if (!result)
            //{
            //    logger.LogError("Failed to create conda environment.");
            //    throw new InvalidOperationException("Could not create conda environment");
            //}
        }
        else
        {
            logger.LogDebug("Conda environment already exists at {fullPath}", fullPath);
            // TODO: Check if the environment is up to date
        }
    }

    public string GetPath()
    {
        // TODO: Conda environments are not always in the same location. Resolve the path correctly. 
        return Path.Combine(conda.CondaHome, "envs", name);
    }
}
@github-actions github-actions bot added the todo label Oct 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

0 participants