/// <summary> /// Create an output "file" and return a handle to it. /// </summary> public static IFileHandle CreateOutputFile(this IHostEnvironment env, string path) { Contracts.AssertValue(env); Contracts.CheckNonWhiteSpace(path, nameof(path)); return(new SimpleFileHandle(env, path, needsWrite: true, autoDelete: false)); }
internal DataOperationsCatalog(IHostEnvironment env) { Contracts.AssertValue(env); _env = env; }
private protected TrainCatalogBase(IHostEnvironment env, string registrationName) { Contracts.CheckValue(env, nameof(env)); env.CheckNonEmpty(registrationName, nameof(registrationName)); Environment = env; }
internal bool TryFindColumn(string name, out Column column) { Contracts.CheckValue(name, nameof(name)); column = _columns.FirstOrDefault(x => x.Name == name); return(column.IsValid); }
public SchemaShape(IEnumerable <Column> columns) { Contracts.CheckValue(columns, nameof(columns)); _columns = columns.ToArray(); Contracts.CheckParam(columns.All(c => c.IsValid), nameof(columns), "Some items are not initialized properly."); }
/// <summary> /// Make sure the given assemblies are loaded and that their loadable classes have been catalogued. /// </summary> public static void LoadAndRegister(IHostEnvironment env, string[] assemblies) { Contracts.AssertValue(env); if (Utils.Size(assemblies) > 0) { foreach (string path in assemblies) { Exception ex = null; try { // REVIEW: Will LoadFrom ever return null? Contracts.CheckNonEmpty(path, nameof(path)); var assem = LoadAssembly(env, path); if (assem != null) { continue; } } catch (Exception e) { ex = e; } // If it is a zip file, load it that way. ZipArchive zip; try { zip = ZipFile.OpenRead(path); } catch (Exception e) { // Couldn't load as an assembly and not a zip, so warn the user. ex = ex ?? e; Console.Error.WriteLine("Warning: Could not load '{0}': {1}", path, ex.Message); continue; } string dir; try { dir = CreateTempDirectory(); } catch (Exception e) { throw Contracts.ExceptIO(e, "Creating temp directory for extra assembly zip extraction failed: '{0}'", path); } try { zip.ExtractToDirectory(dir); } catch (Exception e) { throw Contracts.ExceptIO(e, "Extracting extra assembly zip failed: '{0}'", path); } LoadAssembliesInDir(env, dir, false); } } }
public TelemetryException(Exception exception) { Contracts.AssertValue(exception); Exception = exception; }