Skip to content

Commit

Permalink
feat-fix(config): load support for absolute paths (#1256)
Browse files Browse the repository at this point in the history
  • Loading branch information
EagleoutIce authored Jan 22, 2025
1 parent d4f6519 commit 11d8fed
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/cli/flowr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { defaultConfigFile, flowrMainOptionDefinitions, getScriptsText } from '.
import { TreeSitterExecutor } from '../r-bridge/lang-4.x/tree-sitter/tree-sitter-executor';
import type { KnownParser } from '../r-bridge/parser';
import fs from 'fs';
import path from 'path';

export const toolName = 'flowr';

Expand Down Expand Up @@ -98,7 +99,7 @@ if(options['config-json']) {
if(!usedConfig) {
if(options['config-file']) {
// validate it exists
if(!fs.existsSync(options['config-file'])) {
if(!fs.existsSync(path.resolve(options['config-file']))) {
log.error(`Config file '${options['config-file']}' does not exist`);
process.exit(1);
}
Expand Down
8 changes: 8 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,14 @@ export function getEngineConfig<T extends EngineConfig['type']>(engine: T): Engi

function loadConfigFromFile(configFile: string | undefined, workingDirectory: string): FlowrConfigOptions {
if(configFile !== undefined) {
if(path.isAbsolute(configFile) && fs.existsSync(configFile)) {
log.trace(`Found config at ${configFile} (absolute)`);
const ret = parseConfig(fs.readFileSync(configFile, { encoding: 'utf-8' }));
if(ret) {
log.info(`Using config ${JSON.stringify(ret)}`);
return ret;
}
}
let searchPath = path.resolve(workingDirectory);
do{
const configPath = path.join(searchPath, configFile);
Expand Down

4 comments on commit 11d8fed

@github-actions
Copy link

Choose a reason for hiding this comment

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

"artificial" Benchmark Suite

Benchmark suite Current: 11d8fed Previous: a877df7 Ratio
Retrieve AST from R code 235.3412836363636 ms (96.34275521187959) 239.49771736363638 ms (101.48800821636837) 0.98
Normalize R AST 17.975106181818184 ms (33.907692598318675) 17.41336081818182 ms (30.981566426513265) 1.03
Produce dataflow information 66.79885654545454 ms (141.72377508084395) 68.728513 ms (151.94316854576633) 0.97
Total per-file 811.8568684090909 ms (1453.6807136666475) 837.9476761818181 ms (1510.9729062977526) 0.97
Static slicing 2.066433242962108 ms (1.3416450916508504) 2.0034774339582415 ms (1.1691051705207822) 1.03
Reconstruct code 0.21292378603101506 ms (0.15962769692648707) 0.22634653062782062 ms (0.168666676054442) 0.94
Total per-slice 2.293146683037612 ms (1.390369049009672) 2.24374443748002 ms (1.2384172691894533) 1.02
failed to reconstruct/re-parse 0 # 0 # 1
times hit threshold 0 # 0 # 1
reduction (characters) 0.7891949660994808 # 0.7891949660994808 # 1
reduction (normalized tokens) 0.7665650684287274 # 0.7665650684287274 # 1
memory (df-graph) 95.19682173295455 KiB (244.24808975931026) 95.19682173295455 KiB (244.24808975931026) 1

This comment was automatically generated by workflow using github-action-benchmark.

@github-actions
Copy link

Choose a reason for hiding this comment

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

"social-science" Benchmark Suite

Benchmark suite Current: 11d8fed Previous: a877df7 Ratio
Retrieve AST from R code 243.44993632 ms (45.52815092168418) 240.34012847999998 ms (43.93673078226616) 1.01
Normalize R AST 18.44046666 ms (14.054838669179441) 18.87248132 ms (14.186278380523435) 0.98
Produce dataflow information 78.84394642000001 ms (74.3743609898573) 78.15406248000001 ms (73.48454316898545) 1.01
Total per-file 7529.89570876 ms (29690.472610391564) 7582.25710378 ms (29767.39189439267) 0.99
Static slicing 15.134286321999975 ms (44.8216431199379) 15.270449566508105 ms (44.94967789767313) 0.99
Reconstruct code 0.26279775630863417 ms (0.15400728168658842) 0.2585950662014173 ms (0.1532502183629028) 1.02
Total per-slice 15.405058958862151 ms (44.854429708631464) 15.537331197364793 ms (44.98374295831238) 0.99
failed to reconstruct/re-parse 0 # 0 # 1
times hit threshold 0 # 0 # 1
reduction (characters) 0.8760481407790371 # 0.8760481407790371 # 1
reduction (normalized tokens) 0.8152466834674152 # 0.8152466834674152 # 1
memory (df-graph) 99.6448046875 KiB (113.2159841674677) 99.6448046875 KiB (113.2159841674677) 1

This comment was automatically generated by workflow using github-action-benchmark.

@github-actions
Copy link

Choose a reason for hiding this comment

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

"artificial" Benchmark Suite (tree-sitter)

Benchmark suite Current: 11d8fed Previous: a877df7 Ratio
Retrieve AST from R code 8.048060636363637 ms (9.560492583554305) 8.145506545454547 ms (9.786080094734778) 0.99
Normalize R AST 17.892927227272725 ms (23.676764958532903) 17.78099590909091 ms (23.820712056308647) 1.01
Produce dataflow information 73.5076658181818 ms (155.39709289710038) 70.83680254545455 ms (150.5207252208632) 1.04
Total per-file 625.7049100454545 ms (1434.761417819063) 627.2099676818182 ms (1407.4477264884629) 1.00
Static slicing 2.119673956160102 ms (1.3006464820490506) 2.0248883955065318 ms (1.1173257361688766) 1.05
Reconstruct code 0.23899402419269056 ms (0.18480261820713278) 0.23812396339689798 ms (0.1785232875956438) 1.00
Total per-slice 2.371994406916624 ms (1.3681671629886663) 2.2780515267109083 ms (1.198556469122308) 1.04
failed to reconstruct/re-parse 0 # 0 # 1
times hit threshold 0 # 0 # 1
reduction (characters) 0.7891949660994808 # 0.7891949660994808 # 1
reduction (normalized tokens) 0.7665650684287274 # 0.7665650684287274 # 1
memory (df-graph) 95.19682173295455 KiB (244.24808975931026) 95.19682173295455 KiB (244.24808975931026) 1

This comment was automatically generated by workflow using github-action-benchmark.

@github-actions
Copy link

Choose a reason for hiding this comment

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

"social-science" Benchmark Suite (tree-sitter)

Benchmark suite Current: 11d8fed Previous: a877df7 Ratio
Retrieve AST from R code 10.189792488888889 ms (6.437222115859144) 10.4682258 ms (6.536909762375299) 0.97
Normalize R AST 23.120790066666668 ms (11.77973466550839) 23.515930466666664 ms (11.460003796895084) 0.98
Produce dataflow information 78.34768306666666 ms (66.68401317775462) 77.72576402222222 ms (66.68368526289126) 1.01
Total per-file 7707.477295244445 ms (31327.067541090146) 7557.427238355555 ms (30739.010883053157) 1.02
Static slicing 16.083609800477117 ms (46.53805086754545) 15.83153546219062 ms (45.672079288893144) 1.02
Reconstruct code 0.2972487280748064 ms (0.1706590561765424) 0.2510293465879067 ms (0.15539877495324173) 1.18
Total per-slice 16.38959077476882 ms (46.569064444911) 16.090141405670494 ms (45.71466701697095) 1.02
failed to reconstruct/re-parse 0 # 0 # 1
times hit threshold 0 # 0 # 1
reduction (characters) 0.8685107303274813 # 0.8685107303274813 # 1
reduction (normalized tokens) 0.8049905198879769 # 0.8049905198879769 # 1
memory (df-graph) 97.50590277777778 KiB (111.14577334743846) 97.50590277777778 KiB (111.14577334743846) 1

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.