public static ConfigSet ToEffectiveConfig(this WorkspaceConfig root) { return(new ConfigSet(root.path, GetEffectiveConfig(root).ToDictionary(x => x.Id, x => x))); IEnumerable <IRunnableConfig> GetEffectiveConfig(WorkspaceConfig node) { if (node == null) { return new IRunnableConfig[] { } } ; var configs = node.Elements <IRunnableConfig>() .GroupBy(x => x.Id) .Select(x => x.First()) .ToArray(); if (node.import == null) { return(configs); } var nested = (from w in node.import select GetEffectiveConfig(w)).SelectMany(w => w).ToArray(); return(configs.Concat(nested.Except(configs))); } } }
public override void LoadFromWorkspaceConfig(WorkspaceConfig config, ProjectConfig projectConfig) { if (projectConfig != null) { UpdateCacheModeCheckboxes(projectConfig.AssetCacheMode); } }
public async Task Initialize() { if (!Directory.Exists(TestCaseStoreRoot)) { Directory.CreateDirectory(TestCaseStoreRoot); } if (!Directory.Exists(SubmissionStoreRoot)) { Directory.CreateDirectory(SubmissionStoreRoot); } List <ProgrammingLanguage> langs = new List <ProgrammingLanguage>(); foreach (KeyValuePair <ProgrammingLanguage, JudgerLangConfig> v in Judger.DefaultLangConfigs) { langs.Add(v.Key); } WorkspaceConfig config = new WorkspaceConfig { SupportLanguages = langs }; _context.WorkspaceInfos.RemoveRange(_context.WorkspaceInfos.ToArray()); await _context.SaveChangesAsync(); WorkspaceInfo empty = new WorkspaceInfo { Config = JsonConvert.SerializeObject(config) }; _context.WorkspaceInfos.Add(empty); await _context.SaveChangesAsync(); }
public Workspace(IAptDirectoryPrepService aptDirectoryPrepService, Microsoft.Extensions.Options.IOptions <WorkspaceConfig> workspaceConfig, IAptCacheService aptCacheService, ILogger <Workspace> logger, IAptGetService aptGetService, IDpkgService dpkgService, IProcessRunner processRunner) { _aptDirectoryPrepService = aptDirectoryPrepService; _aptCacheService = aptCacheService; _logger = logger; _aptGetService = aptGetService; _dpkgService = dpkgService; _processRunner = processRunner; _workspaceConfig = workspaceConfig.Value; }
private async Task <ConfigSet> LoadConfigurationAsync(ConfiguratorPaths paths) { WorkspaceConfig tree = null; const int retries = 5; var tryCount = retries; while (tryCount > 0) { try { tryCount--; tree = _configReader.GetConfigTree(paths); break; } catch (Exception ex) { _logger.LogError(ex, $"Could not open workspace '{paths.WorkspacePath}'. {tryCount} retries left"); await Task.Delay(1000); } } if (tree == null) { throw new FileLoadException($"Could not (re)load workspace after {retries} tries. Path: '{paths.WorkspacePath}'"); } var effectiveConfig = tree.ToEffectiveConfig(); using (_logger.WithHostScope(Phase.CONFIG)) { _logger.LogInformation("Workspace: {WorkspaceFile}", paths.WorkspacePath); _logger.LogInformation(PhaseStatus.OK); } Current = effectiveConfig; return(effectiveConfig); }
public override void LoadFromWorkspaceConfig(WorkspaceConfig config) => UpdateCacheModeCheckboxes(config.AssetCacheMode);
public KrutaConfig() { WorkspaceConfig = new WorkspaceConfig();; }