Skip to content

Align with changes in oM and Engine on Reflection -> Base #71

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

Merged
merged 2 commits into from
Jan 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Python_Engine/Compute/DownloadFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* along with this code. If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
*/

using BH.oM.Reflection.Attributes;
using BH.oM.Base.Attributes;

using System.ComponentModel;
using System.IO;
Expand Down Expand Up @@ -49,7 +49,7 @@ public static string DownloadFile(string url, string directory = null, bool forc
return downloadedFile;
}

BH.Engine.Reflection.Compute.RecordError($"Download of {Path.GetFileName(url)} to {directory} did not work.");
BH.Engine.Base.Compute.RecordError($"Download of {Path.GetFileName(url)} to {directory} did not work.");

return null;
}
Expand Down
2 changes: 1 addition & 1 deletion Python_Engine/Compute/InstallPythonEnvironment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*/

using BH.oM.Python;
using BH.oM.Reflection.Attributes;
using BH.oM.Base.Attributes;

using System.Collections.Generic;
using System.ComponentModel;
Expand Down
6 changes: 3 additions & 3 deletions Python_Engine/Compute/InstallPythonPackages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*/

using BH.oM.Python;
using BH.oM.Reflection.Attributes;
using BH.oM.Base.Attributes;

using System;
using System.Collections.Generic;
Expand All @@ -45,7 +45,7 @@ public static PythonEnvironment InstallPythonPackages(this PythonEnvironment pyt
return null;
if (Query.LoadPythonEnvironment(pythonEnvironment.Name) == null)
{
BH.Engine.Reflection.Compute.RecordError("The environment given doesn't exist.");
BH.Engine.Base.Compute.RecordError("The environment given doesn't exist.");
return null;
}

Expand All @@ -59,7 +59,7 @@ public static PythonEnvironment InstallPythonPackages(this PythonEnvironment pyt
string command = $"{Query.PythonExecutable(pythonEnvironment)} -m pip install --no-warn-script-location{(force ? " --force-reinstall" : "")} {String.Join(" ", packagesStrings)} > {Path.Combine(pythonEnvironment.EnvironmentDirectory(), "package_install.log")} && exit";
if (!Compute.RunCommandBool(command, hideWindows: true))
{
BH.Engine.Reflection.Compute.RecordError($"Packages not installed for some reason.");
BH.Engine.Base.Compute.RecordError($"Packages not installed for some reason.");
return null;
}
}
Expand Down
8 changes: 4 additions & 4 deletions Python_Engine/Compute/InstallPythonToolkit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@

using System;
using System.Collections.Generic;
using BH.oM.Reflection.Attributes;
using BH.oM.Base.Attributes;
using System.ComponentModel;
using BH.oM.Reflection;
using BH.oM.Base;
using System.IO;

namespace BH.Engine.Python
Expand All @@ -49,7 +49,7 @@ public static Output<bool, List<string>> InstallPythonToolkit(bool run = false,
Console.WriteLine("Installing python 3.7 embedded...");
if (!Compute.InstallPython(force))
{
BH.Engine.Reflection.Compute.RecordError("Coule not install Python");
BH.Engine.Base.Compute.RecordError("Coule not install Python");
return new Output<bool, List<string>> { Item1 = success, Item2 = installedPackages };
}
installedPackages.Add("Python 3.7");
Expand All @@ -58,7 +58,7 @@ public static Output<bool, List<string>> InstallPythonToolkit(bool run = false,
Console.WriteLine("Installing pip...");
if (!Compute.InstallPip())
{
BH.Engine.Reflection.Compute.RecordError("Could not install pip");
BH.Engine.Base.Compute.RecordError("Could not install pip");
return new Output<bool, List<string>> { Item1 = success, Item2 = installedPackages };
}

Expand Down
14 changes: 7 additions & 7 deletions Python_Engine/Compute/InstallToolkitPythonEnvironment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*/

using BH.oM.Python;
using BH.oM.Reflection.Attributes;
using BH.oM.Base.Attributes;
using System;
using System.Collections.Generic;
using System.ComponentModel;
Expand All @@ -39,7 +39,7 @@ public static partial class Compute
[Output("pythonEnvironment", "A BHoM PythonEnvironment object.")]
public static PythonEnvironment InstallToolkitPythonEnvironment(this PythonEnvironment pythonEnvironment, bool force = false, bool run = false)
{
BH.Engine.Reflection.Compute.RecordNote($"This component will install a Python environment for {pythonEnvironment.Name}.");
BH.Engine.Base.Compute.RecordNote($"This component will install a Python environment for {pythonEnvironment.Name}.");

if (!run)
return null;
Expand All @@ -52,7 +52,7 @@ public static PythonEnvironment InstallToolkitPythonEnvironment(this PythonEnvir
{
if (existingEnvironment.Version != pythonEnvironment.Version)
{
BH.Engine.Reflection.Compute.RecordError($"An environment exists with the given name, but its Python version does not match the given version. To overwrite this existing environment set \"force\" to True.");
BH.Engine.Base.Compute.RecordError($"An environment exists with the given name, but its Python version does not match the given version. To overwrite this existing environment set \"force\" to True.");
return null;
}

Expand All @@ -62,7 +62,7 @@ public static PythonEnvironment InstallToolkitPythonEnvironment(this PythonEnvir
{
if (!existingPackages.PackageInList(pkg))
{
BH.Engine.Reflection.Compute.RecordError($"An environment exists with the given name, but it doesn't contain {pkg.GetString()}. To overwrite this existing environment set \"force\" to True.");
BH.Engine.Base.Compute.RecordError($"An environment exists with the given name, but it doesn't contain {pkg.GetString()}. To overwrite this existing environment set \"force\" to True.");
return null;
}
}
Expand All @@ -89,7 +89,7 @@ public static PythonEnvironment InstallToolkitPythonEnvironment(this PythonEnvir
string installPipCommand = $"{pythonEnvironment.PythonExecutable()} {pipInstallerPy} && exit";
if (!Compute.RunCommandBool(installPipCommand, hideWindows: true))
{
BH.Engine.Reflection.Compute.RecordError($"Pip installation did not work using the command {installPipCommand}.");
BH.Engine.Base.Compute.RecordError($"Pip installation did not work using the command {installPipCommand}.");
return null;
}

Expand All @@ -103,7 +103,7 @@ public static PythonEnvironment InstallToolkitPythonEnvironment(this PythonEnvir
}
catch (Exception e)
{
BH.Engine.Reflection.Compute.RecordError($"{pthFile} not found to be deleted: {e}.");
BH.Engine.Base.Compute.RecordError($"{pthFile} not found to be deleted: {e}.");
return null;
}
}
Expand All @@ -120,7 +120,7 @@ public static PythonEnvironment InstallToolkitPythonEnvironment(this PythonEnvir
}
catch (Exception e)
{
BH.Engine.Reflection.Compute.RecordError($"{libFile} not capable of being moved to {newLibFile}: {e}.");
BH.Engine.Base.Compute.RecordError($"{libFile} not capable of being moved to {newLibFile}: {e}.");
return null;
}
}
Expand Down
4 changes: 2 additions & 2 deletions Python_Engine/Compute/RemoveEnvironment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*/

using BH.oM.Python;
using BH.oM.Reflection.Attributes;
using BH.oM.Base.Attributes;

using System.ComponentModel;
using System.IO;
Expand Down Expand Up @@ -49,7 +49,7 @@ public static bool RemoveEnvironment(this PythonEnvironment pythonEnvironment, b
}
catch (System.Exception e)
{
BH.Engine.Reflection.Compute.RecordError($"Cannot fully remove the environment. You may have the directory, or a file within it open in another program. Original error code: {e}");
BH.Engine.Base.Compute.RecordError($"Cannot fully remove the environment. You may have the directory, or a file within it open in another program. Original error code: {e}");
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion Python_Engine/Compute/RunCommandBool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* along with this code. If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
*/

using BH.oM.Reflection.Attributes;
using BH.oM.Base.Attributes;

using System.ComponentModel;

Expand Down
2 changes: 1 addition & 1 deletion Python_Engine/Compute/RunCommandStdout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* along with this code. If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
*/

using BH.oM.Reflection.Attributes;
using BH.oM.Base.Attributes;

using System.ComponentModel;

Expand Down
10 changes: 5 additions & 5 deletions Python_Engine/Compute/RunPythonScript.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

using BH.oM.Base;
using BH.oM.Python;
using BH.oM.Reflection.Attributes;
using BH.oM.Base.Attributes;

using System.Collections.Generic;
using System.ComponentModel;
Expand All @@ -48,7 +48,7 @@ public static CustomObject RunPythonScript(this PythonEnvironment pythonEnvironm

if (!File.Exists(pythonScript))
{
BH.Engine.Reflection.Compute.RecordError($"{pythonScript} does not exist.");
BH.Engine.Base.Compute.RecordError($"{pythonScript} does not exist.");
return null;
}

Expand All @@ -64,7 +64,7 @@ public static CustomObject RunPythonScript(this PythonEnvironment pythonEnvironm
};
if (!executableStrings.Any(contents.Contains))
{
BH.Engine.Reflection.Compute.RecordError($"The script passed does not seem to be directly executable using Python. It should contain an 'if __name__ == \"__main__\"' to enable the file to be called directly.");
BH.Engine.Base.Compute.RecordError($"The script passed does not seem to be directly executable using Python. It should contain an 'if __name__ == \"__main__\"' to enable the file to be called directly.");
return null;
}

Expand All @@ -83,11 +83,11 @@ public static CustomObject RunPythonScript(this PythonEnvironment pythonEnvironm
{
if (arguments.Contains("-h"))
{
BH.Engine.Reflection.Compute.RecordNote($"It looks like you've asked for some documentation. Here it is!");
BH.Engine.Base.Compute.RecordNote($"It looks like you've asked for some documentation. Here it is!");
}
else
{
BH.Engine.Reflection.Compute.RecordError($"Something went wrong! The object returned contains the error message given by the Python code.");
BH.Engine.Base.Compute.RecordError($"Something went wrong! The object returned contains the error message given by the Python code.");
}

return new CustomObject()
Expand Down
4 changes: 2 additions & 2 deletions Python_Engine/Compute/RunPythonString.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*/

using BH.oM.Python;
using BH.oM.Reflection.Attributes;
using BH.oM.Base.Attributes;

using System.Collections.Generic;
using System.ComponentModel;
Expand All @@ -41,7 +41,7 @@ public static string RunPythonString(this PythonEnvironment pythonEnvironment, s

if (!pythonString.Contains("print"))
{
BH.Engine.Reflection.Compute.RecordWarning("Nothing is being passed to Stdout in the Python script, so nothing will be returned from this method.");
BH.Engine.Base.Compute.RecordWarning("Nothing is being passed to Stdout in the Python script, so nothing will be returned from this method.");
}

// place pythonScript into a temporary .py file ready to reference and run, then call using the passed executable
Expand Down
2 changes: 1 addition & 1 deletion Python_Engine/Convert/FromPython.cs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public static List<object> FromPython(this PyIter input)

private static object FromPython(this object obj)
{
Engine.Reflection.Compute.RecordError($"Cannot convert from Python object of type {obj.GetType()}");
Engine.Base.Compute.RecordError($"Cannot convert from Python object of type {obj.GetType()}");
return null;
}

Expand Down
6 changes: 3 additions & 3 deletions Python_Engine/Convert/GetString.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*/

using BH.oM.Python;
using BH.oM.Reflection.Attributes;
using BH.oM.Base.Attributes;

using System.ComponentModel;

Expand All @@ -36,7 +36,7 @@ public static string GetString(this PythonPackage package)
{
if (package.Name == "" || package.Version == "")
{
BH.Engine.Reflection.Compute.RecordError("The package is not valid as it does not contain either a name or version.");
BH.Engine.Base.Compute.RecordError("The package is not valid as it does not contain either a name or version.");
return "";
}
return $"{package.Name}=={package.Version}";
Expand All @@ -49,7 +49,7 @@ public static string GetString(this PythonEnvironment pythonEnvironment)
{
if (pythonEnvironment.Name == "" || pythonEnvironment.Version == oM.Python.Enums.PythonVersion.Undefined)
{
BH.Engine.Reflection.Compute.RecordError("The environment is not valid as it does not contain either a name or version.");
BH.Engine.Base.Compute.RecordError("The environment is not valid as it does not contain either a name or version.");
return "";
}
return $"Environment: {pythonEnvironment.Name}\nVersion: {pythonEnvironment.Version}\nLocation: {Query.EnvironmentDirectory(pythonEnvironment)}";
Expand Down
2 changes: 1 addition & 1 deletion Python_Engine/Convert/ToPython.cs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ public static PyTuple ToPython(this ValueTuple<int, int, int> input)

private static PyObject ToPython(this object obj)
{
Engine.Reflection.Compute.RecordError($"Cannot convert to Python object of type {obj.GetType()}");
Engine.Base.Compute.RecordError($"Cannot convert to Python object of type {obj.GetType()}");
return null;
}

Expand Down
6 changes: 3 additions & 3 deletions Python_Engine/Create/PythonEnvironment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

using BH.oM.Python.Enums;
using BH.oM.Python;
using BH.oM.Reflection.Attributes;
using BH.oM.Base.Attributes;

using System.Collections.Generic;
using System.ComponentModel;
Expand All @@ -43,13 +43,13 @@ public static PythonEnvironment PythonEnvironment(string name, PythonVersion ver
{
if (name.Any(x => Char.IsWhiteSpace(x)))
{
BH.Engine.Reflection.Compute.RecordError($"A BHoM PythonEnvironment name cannot contain whitespace characters.");
BH.Engine.Base.Compute.RecordError($"A BHoM PythonEnvironment name cannot contain whitespace characters.");
return null;
}

if (version == PythonVersion.Undefined)
{
BH.Engine.Reflection.Compute.RecordError($"The Python version chosen cannot be \"Undefined\".");
BH.Engine.Base.Compute.RecordError($"The Python version chosen cannot be \"Undefined\".");
return null;
}

Expand Down
8 changes: 4 additions & 4 deletions Python_Engine/Create/PythonPackage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*/

using BH.oM.Python;
using BH.oM.Reflection.Attributes;
using BH.oM.Base.Attributes;

using System.ComponentModel;
using System.Linq;
Expand All @@ -39,19 +39,19 @@ public static PythonPackage PythonPackage(string name, string version)
{
if (name == "" || version == "")
{
BH.Engine.Reflection.Compute.RecordError($"The package name or version is not valid.");
BH.Engine.Base.Compute.RecordError($"The package name or version is not valid.");
return null;
}

if (name.Any(x => Char.IsWhiteSpace(x)))
{
BH.Engine.Reflection.Compute.RecordError($"A PythonPackage name cannot contain whitespace characters.");
BH.Engine.Base.Compute.RecordError($"A PythonPackage name cannot contain whitespace characters.");
return null;
}

if (version.Any(x => Char.IsWhiteSpace(x)))
{
BH.Engine.Reflection.Compute.RecordError($"A PythonPackage version cannot contain whitespace characters.");
BH.Engine.Base.Compute.RecordError($"A PythonPackage version cannot contain whitespace characters.");
return null;
}

Expand Down
2 changes: 1 addition & 1 deletion Python_Engine/Modify/AddQuotesIfRequired.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* along with this code. If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
*/

using BH.oM.Reflection.Attributes;
using BH.oM.Base.Attributes;
using System;
using System.Collections.Generic;
using System.ComponentModel;
Expand Down
14 changes: 7 additions & 7 deletions Python_Engine/Python_Engine.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
Expand Down Expand Up @@ -36,6 +36,11 @@
<HintPath>C:\ProgramData\BHoM\Assemblies\BHoM.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="BHoM_Engine">
<HintPath>C:\ProgramData\BHoM\Assemblies\BHoM_Engine.dll</HintPath>
<Private>False</Private>
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="Python.Runtime, Version=3.7.4.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\libs\Python.Runtime.dll</HintPath>
Expand All @@ -45,11 +50,6 @@
<HintPath>C:\ProgramData\BHoM\Assemblies\Reflection_Engine.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Reflection_oM">
<SpecificVersion>False</SpecificVersion>
<HintPath>C:\ProgramData\BHoM\Assemblies\Reflection_oM.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Serialiser_Engine">
<SpecificVersion>False</SpecificVersion>
<HintPath>C:\ProgramData\BHoM\Assemblies\Serialiser_Engine.dll</HintPath>
Expand Down Expand Up @@ -151,4 +151,4 @@ if exist "C:\ProgramData\BHoM\Extensions\PythonCode\$(SolutionName)" rmdir "C:\P
robocopy "$(ProjectDir)Python" "C:\ProgramData\BHoM\Extensions\PythonCode\$(SolutionName)" /s /purge /xf "*.pyc" /xd "\__pycache__\" &gt; output.log
del output.log</PostBuildEvent>
</PropertyGroup>
</Project>
</Project>
Loading