Merge pull request #1798 from papillot/remove-promisify

remove utils.promisify dependency
This commit is contained in:
Alexander Rose
2026-03-26 14:46:44 -07:00
committed by GitHub
16 changed files with 11264 additions and 12494 deletions

View File

@@ -4,6 +4,7 @@ All notable changes to this project will be documented in this file, following t
Note that since we don't clearly distinguish between a public and private interfaces there will be changes in non-major versions that are potentially breaking. If we make breaking changes to less used interfaces we will highlight it in here.
## [Unreleased]
- Dependencies: remove `utils.promisify` (#1797)
- Fix circular dependency which causes crash in bundlers (#1791)
- Add `putty` as a mol-view-spec representation.
- Fix detecting sidechain-only structures as coarse-grained (#1420)

23662
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -179,8 +179,7 @@
"remark-gfm": "^4.0.1",
"rxjs": "^7.8.2",
"swagger-ui-dist": "^5.32.0",
"tslib": "^2.8.1",
"util.promisify": "^1.1.3"
"tslib": "^2.8.1"
},
"peerDependencies": {
"@google-cloud/storage": "^7.14.0",

View File

@@ -1,17 +1,16 @@
#!/usr/bin/env node
/**
* Copyright (c) 2020-2022 mol* contributors, licensed under MIT, See LICENSE file for more info.
* Copyright (c) 2020-2026 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author Josh McMenemy <josh.mcmenemy@gmail.com>
* @author Alexander Rose <alexander.rose@weirdbyte.de>
* @author Paul Pillot <paul.pillot@tandemai.com>
*/
import * as argparse from 'argparse';
import * as path from 'path';
import util from 'util';
import fs from 'fs';
require('util.promisify').shim();
const writeFile = util.promisify(fs.writeFile);
const writeFileAsync = fs.promises.writeFile;
import { DatabaseCollection } from '../../mol-data/db';
import { CCD_Schema } from '../../mol-io/reader/cif/schema/ccd';
@@ -32,7 +31,7 @@ function extractIonNames(ccd: DatabaseCollection<CCD_Schema>) {
function writeIonNamesFile(filePath: string, ionNames: string[]) {
const output = `/**
* Copyright (c) 2020-2022 mol* contributors, licensed under MIT, See LICENSE file for more info.
* Copyright (c) 2020-2026 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* Code-generated ion names params file. Names extracted from CCD components.
*
@@ -41,7 +40,7 @@ function writeIonNamesFile(filePath: string, ionNames: string[]) {
export const IonNames = new Set(${JSON.stringify(ionNames).replace(/"/g, "'").replace(/,/g, ', ')});
`;
writeFile(filePath, output);
writeFileAsync(filePath, output);
}
async function run(out: string, options = DefaultDataOptions) {

View File

@@ -1,16 +1,15 @@
#!/usr/bin/env node
/**
* Copyright (c) 2022 mol* contributors, licensed under MIT, See LICENSE file for more info.
* Copyright (c) 2022-2026 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author Alexander Rose <alexander.rose@weirdbyte.de>
* @author Paul Pillot <paul.pillot@tandemai.com>
*/
import * as argparse from 'argparse';
import * as path from 'path';
import util from 'util';
import fs from 'fs';
require('util.promisify').shim();
const writeFile = util.promisify(fs.writeFile);
const writeFileAsync = fs.promises.writeFile;
import { DatabaseCollection } from '../../mol-data/db';
import { CCD_Schema } from '../../mol-io/reader/cif/schema/ccd';
@@ -44,7 +43,7 @@ function writeSaccharideNamesFile(filePath: string, ionNames: string[]) {
export const SaccharideNames = new Set(${JSON.stringify(ionNames).replace(/"/g, "'").replace(/,/g, ', ')});
`;
writeFile(filePath, output);
writeFileAsync(filePath, output);
}
async function run(out: string, options = DefaultDataOptions) {

View File

@@ -1,16 +1,15 @@
#!/usr/bin/env node
/**
* Copyright (c) 2018-2020 mol* contributors, licensed under MIT, See LICENSE file for more info.
* Copyright (c) 2018-2026 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author Alexander Rose <alexander.rose@weirdbyte.de>
* @author Paul Pillot <paul.pillot@tandemai.com>
*/
import * as argparse from 'argparse';
import * as util from 'util';
import * as path from 'path';
import * as fs from 'fs';
require('util.promisify').shim();
const writeFile = util.promisify(fs.writeFile);
const writeFileAsync = fs.promises.writeFile;
import { Database, Table, DatabaseCollection } from '../../mol-data/db';
import { CCD_Schema } from '../../mol-io/reader/cif/schema/ccd';
@@ -250,14 +249,14 @@ async function run(out: string, binary = false, options = DefaultDataOptions, cc
if (!fs.existsSync(path.dirname(out))) {
fs.mkdirSync(path.dirname(out));
}
writeFile(out, ccbCif);
writeFileAsync(out, ccbCif);
if (!!ccaOut) {
const ccaCif = getEncodedCif(CCA_TABLE_NAME, atoms, binary);
if (!fs.existsSync(path.dirname(ccaOut))) {
fs.mkdirSync(path.dirname(ccaOut));
}
writeFile(ccaOut, ccaCif);
writeFileAsync(ccaOut, ccaCif);
}
}

View File

@@ -1,17 +1,16 @@
/**
* Copyright (c) 2018-2020 mol* contributors, licensed under MIT, See LICENSE file for more info.
* Copyright (c) 2018-2026 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author Alexander Rose <alexander.rose@weirdbyte.de>
* @author Paul Pillot <paul.pillot@tandemai.com>
*/
import * as util from 'util';
import * as path from 'path';
import * as fs from 'fs';
import * as zlib from 'zlib';
import fetch from 'node-fetch';
require('util.promisify').shim();
const readFile = util.promisify(fs.readFile);
const writeFile = util.promisify(fs.writeFile);
const readFileAsync = fs.promises.readFile;
const writeFileAsync = fs.promises.writeFile;
import { Progress } from '../../mol-task';
import { Database } from '../../mol-data/db';
@@ -27,9 +26,9 @@ export async function ensureAvailable(path: string, url: string, forceDownload =
fs.mkdirSync(DATA_DIR);
}
if (url.endsWith('.gz')) {
await writeFile(path, zlib.gunzipSync(await data.buffer()));
await writeFileAsync(path, zlib.gunzipSync(await data.buffer()));
} else {
await writeFile(path, await data.text());
await writeFileAsync(path, await data.text());
}
console.log(`done downloading ${url}`);
}
@@ -41,7 +40,7 @@ export async function ensureDataAvailable(options: DataOptions) {
}
export async function readFileAsCollection<S extends Database.Schema>(path: string, schema: S) {
const parsed = await parseCif(await readFile(path, 'utf8'));
const parsed = await parseCif(await readFileAsync(path, 'utf8'));
return CIF.toDatabaseCollection(schema, parsed.result);
}

View File

@@ -1,8 +1,9 @@
/**
* Copyright (c) 2017 mol* contributors, licensed under MIT, See LICENSE file for more info.
* Copyright (c) 2017-2026 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author David Sehnal <david.sehnal@gmail.com>
* @author Sebastian Bittrich <sebastian.bittrich@rcsb.org>
* @author Paul Pillot <paul.pillot@tandemai.com>
*/
import { CIF, CifCategory, getCifFieldType, CifField, CifFile } from '../../mol-io/reader/cif';
@@ -22,7 +23,7 @@ function showProgress(p: Progress) {
process.stdout.write(`\r${Progress.format(p)}`);
}
const readFileAsync = util.promisify(fs.readFile);
const readFileAsync = fs.promises.readFile;
const unzipAsync = util.promisify<zlib.InputType, Buffer>(zlib.unzip);
async function readFile(ctx: RuntimeContext, filename: string): Promise<ReaderResult<CifFile>> {

View File

@@ -12,7 +12,6 @@ import * as fs from 'fs';
import * as zlib from 'zlib';
import { convert } from './converter';
require('util.promisify').shim();
async function process(srcPath: string, outPath: string, configPath?: string, filterPath?: string) {
const config = configPath ? JSON.parse(fs.readFileSync(configPath, 'utf8')) : void 0;

View File

@@ -1,18 +1,17 @@
/**
* Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info.
* Copyright (c) 2018-2026 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author David Sehnal <david.sehnal@gmail.com>
* @author Paul Pillot <paul.pillot@tandemai.com>
*/
import * as util from 'util';
import * as fs from 'fs';
import fetch from 'node-fetch';
require('util.promisify').shim();
import { CIF } from '../../mol-io/reader/cif';
import { Progress } from '../../mol-task';
const readFileAsync = util.promisify(fs.readFile);
const readFileAsync = fs.promises.readFile;
async function readFile(path: string) {
if (path.match(/\.bcif$/)) {

View File

@@ -7,7 +7,6 @@
*/
import * as argparse from 'argparse';
require('util.promisify').shim();
import { CifFrame } from '../../mol-io/reader/cif';
import { Model, Structure, StructureElement, Unit, StructureProperties, UnitRing, Trajectory } from '../../mol-model/structure';

View File

@@ -1,14 +1,14 @@
#!/usr/bin/env node
/**
* Copyright (c) 2018-2025 mol* contributors, licensed under MIT, See LICENSE file for more info.
* Copyright (c) 2018-2026 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author David Sehnal <david.sehnal@gmail.com>
* @author Alexander Rose <alexander.rose@weirdbyte.de>
* @author Paul Pillot <paul.pillot@tandemai.com>
*/
import * as fs from 'fs';
import * as argparse from 'argparse';
import * as util from 'util';
import { Volume } from '../../mol-model/volume';
import { downloadCif } from './helpers';
@@ -20,8 +20,7 @@ import { createVolumeIsosurfaceMesh } from '../../mol-repr/volume/isosurface';
import { Theme } from '../../mol-theme/theme';
import { volumeFromDensityServerData, DscifFormat } from '../../mol-model-formats/volume/density-server';
require('util.promisify').shim();
const writeFileAsync = util.promisify(fs.writeFile);
const writeFileAsync = fs.promises.writeFile;
async function getVolume(url: string): Promise<Volume> {
const cif = await downloadCif(url, true);

View File

@@ -1,4 +1,3 @@
import * as util from 'util';
import * as fs from 'fs';
import { CIF } from '../mol-io/reader/cif';
@@ -10,8 +9,7 @@ import { OrderedSet } from '../mol-data/int';
import { trajectoryFromMmCIF, MmcifFormat } from '../mol-model-formats/structure/mmcif';
import { getBoundary } from '../mol-math/geometry/boundary';
require('util.promisify').shim();
const readFileAsync = util.promisify(fs.readFile);
const readFileAsync = fs.promises.readFile;
async function readData(path: string) {
if (path.match(/\.bcif$/)) {

View File

@@ -1,12 +1,12 @@
/**
* Copyright (c) 2017 mol* contributors, licensed under MIT, See LICENSE file for more info.
* Copyright (c) 2017-2026 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author David Sehnal <david.sehnal@gmail.com>
* @author Paul Pillot <paul.pillot@tandemai.com>
*/
import * as B from 'benchmark';
import * as util from 'util';
import * as fs from 'fs';
import fetch from 'node-fetch';
import { CIF } from '../mol-io/reader/cif';
@@ -20,9 +20,8 @@ import { trajectoryFromMmCIF, MmcifFormat } from '../mol-model-formats/structure
// import { printUnits } from '../apps/structure-info/model';
// import { EquivalenceClasses } from '../mol-data/util';
require('util.promisify').shim();
const readFileAsync = util.promisify(fs.readFile);
const writeFileAsync = util.promisify(fs.writeFile);
const readFileAsync = fs.promises.readFile;
const writeFileAsync = fs.promises.writeFile;
async function readData(path: string) {
if (path.match(/\.bcif$/)) {

View File

@@ -1,11 +1,11 @@
/**
* Copyright (c) 2019-2020 mol* contributors, licensed under MIT, See LICENSE file for more info.
* Copyright (c) 2019-2026 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author Alexander Rose <alexander.rose@weirdbyte.de>
* @author Paul Pillot <paul.pillot@tandemai.com>
*/
import * as fs from 'fs';
import * as util from 'util';
import { AttachModelProperty } from '../../property-provider';
import { CIF } from '../../../../mol-io/reader/cif';
import { getParam } from '../../../common/util';
@@ -14,8 +14,7 @@ import { ComponentBond } from '../../../../mol-model-formats/structure/property/
import { ComponentAtom } from '../../../../mol-model-formats/structure/property/atoms/chem_comp';
import { CCD_Database, CCD_Schema } from '../../../../mol-io/reader/cif/schema/ccd';
require('util.promisify').shim();
const readFile = util.promisify(fs.readFile);
const readFileAsync = fs.promises.readFile;
export const wwPDB_chemCompBond: AttachModelProperty = async ({ model, params }) => {
const table = await getChemCompBondTable(getBondTablePath(params));
@@ -25,7 +24,7 @@ export const wwPDB_chemCompBond: AttachModelProperty = async ({ model, params })
};
async function read(path: string) {
return path.endsWith('.bcif') ? new Uint8Array(await readFile(path)) : readFile(path, 'utf8');
return path.endsWith('.bcif') ? new Uint8Array(await readFileAsync(path)) : readFileAsync(path, 'utf8');
}
let chemCompBondTable: mmCIF_Database['chem_comp_bond'];

View File

@@ -19,7 +19,6 @@ import { trajectoryFromMmCIF } from '../../../mol-model-formats/structure/mmcif'
import { fetchRetry } from '../utils/fetch-retry';
import { Task } from '../../../mol-task';
require('util.promisify').shim();
export enum StructureSourceType {
File,
@@ -65,7 +64,7 @@ export async function createStructureWrapperFromJobEntry(entry: JobEntry, proper
export const StructureCache = new Cache<StructureWrapper>(s => s.key, s => s.approximateSize);
const perf = new PerformanceMonitor();
const readFileAsync = util.promisify(fs.readFile);
const readFileAsync = fs.promises.readFile;
const unzipAsync = util.promisify<zlib.InputType, Buffer>(zlib.unzip);
async function readFile(filename: string) {