Skip to content

Commit

Permalink
Merge pull request #18 from Exabyte-io/update/SOF-7521-fix
Browse files Browse the repository at this point in the history
Update/SOF-7521 fix
  • Loading branch information
timurbazhirov authored Dec 19, 2024
2 parents ce68f58 + b074461 commit 0281314
Show file tree
Hide file tree
Showing 29 changed files with 7,362 additions and 2,730 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,6 @@
"@typescript-eslint"
]
}
]
],
"ignorePatterns": ["dist/*"]
}
16 changes: 10 additions & 6 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-20.04
strategy:
matrix:
python-version: [3.8.6]
python-version: [3.10.13]

steps:
- name: Checkout this repository
Expand Down Expand Up @@ -48,7 +48,11 @@ jobs:
runs-on: ubuntu-20.04
strategy:
matrix:
python-version: [3.8.6, 3.9.x]
python-version:
- 3.10.x
- 3.11.x
- 3.12.x
- 3.13.x

steps:
- name: Checkout this repository
Expand All @@ -73,7 +77,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [14.x, 20.x]
node-version: [20.x]

steps:
- name: Checkout this repository
Expand All @@ -91,7 +95,7 @@ jobs:
- name: Run JS validate
uses: ./actions/js/validate
with:
node-version: '14.x'
node-version: '20.x'
skip-eslint: 'true'

- name: Run JS tests
Expand Down Expand Up @@ -119,7 +123,7 @@ jobs:
- name: Publish JS release
uses: ./actions/js/publish
with:
node-version: 14.19.x
node-version: 20.x
npm-token: ${{ secrets.NPM_TOKEN }}
github-token: ${{ secrets.BOT_GITHUB_TOKEN }}
publish-tag: 'true'
Expand All @@ -145,7 +149,7 @@ jobs:
- name: Publish python release
uses: ./actions/py/publish
with:
python-version: 3.x
python-version: 3.10.13
github-token: ${{ secrets.BOT_GITHUB_TOKEN }}
pypi-api-token: ${{ secrets.PYPI_API_TOKEN }}
publish-tag: 'false'
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ __pycache__/
build/
!src/py/mat3ra/standata/build
develop-eggs/
dist/
#dist/
downloads/
eggs/
.eggs/
Expand Down Expand Up @@ -122,7 +122,7 @@ celerybeat.pid

# Environments
.env
.venv
.venv*
env/
venv/
ENV/
Expand Down
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ repos:
pass_filenames: false
verbose: true
files: ^materials/sources/|create_materials.py
- id: recreate-runtime-date
name: recreate-runtime-date
- id: recreate-dist
name: recreate-dist
language: system
entry: npm run build:runtime-data && exit 0
entry: npm run build:dist && exit 0
pass_filenames: false
verbose: true
files: ^materials|applications|workflows|properties/
Expand Down
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Standard data for digital materials R&D entities in the [ESSE](https://github.co

### 1.1. Python

The package is compatible with Python 3.8+. It can be installed as a Python package either via PyPI:
The package is compatible with Python 3.10+. It can be installed as a Python package either via PyPI:

```shell
pip install mat3ra-standata
Expand Down Expand Up @@ -164,5 +164,3 @@ Brackets: Wrap common name and identifier parts in square brackets `[]`.
- C-[Graphene]-HEX_[P6%2Fmmm]_2D_[Monolayer]-[mp-1040425]

## 5. Links

To be added here.
9 changes: 5 additions & 4 deletions build_runtime_data.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,24 @@ function buildAsset({
console.log(`Written entity category map to "${assetPath}" to "${targetPath}"`);
}

const runtimeDataDir = "./dist/js/runtime_data";
// JS Modules

buildAsset({
assetPath: "./materials/categories.yml",
targetPath: "./src/js/runtime_data/materials.json",
targetPath: `${runtimeDataDir}/materials.json`,
});
buildAsset({
assetPath: "./properties/categories.yml",
targetPath: "./src/js/runtime_data/properties.json",
targetPath: `${runtimeDataDir}/properties.json`,
});
buildAsset({
assetPath: "./applications/categories.yml",
targetPath: "./src/js/runtime_data/applications.json",
targetPath: `${runtimeDataDir}/applications.json`,
});
buildAsset({
assetPath: "./workflows/categories.yml",
targetPath: "./src/js/runtime_data/workflows.json",
targetPath: `${runtimeDataDir}/workflows.json`,
});

// Py Modules
Expand Down
36 changes: 36 additions & 0 deletions dist/js/application.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { Standata } from "./base";
export declare class ApplicationStandata extends Standata {
static runtimeData: {
standataConfig: {
categories: {
model: string[];
language_type: string[];
purpose: string[];
};
entities: {
filename: string;
categories: string[];
}[];
};
filesMapByName: {
"espresso_gnu_540.json": {
name: string;
shortName: string;
summary: string;
version: string;
build: string;
hasAdvancedComputeOptions: boolean;
isLicensed: boolean;
};
"python_386.json": {
name: string;
shortName: string;
summary: string;
version: string;
build: string;
hasAdvancedComputeOptions: boolean;
isLicensed: boolean;
};
};
};
}
13 changes: 13 additions & 0 deletions dist/js/application.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
"use strict";
var __importDefault =
(this && this.__importDefault) ||
function (mod) {
return mod && mod.__esModule ? mod : { default: mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ApplicationStandata = void 0;
const base_1 = require("./base");
const applications_json_1 = __importDefault(require("./runtime_data/applications.json"));
class ApplicationStandata extends base_1.Standata {}
exports.ApplicationStandata = ApplicationStandata;
ApplicationStandata.runtimeData = applications_json_1.default;
35 changes: 35 additions & 0 deletions dist/js/base.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
interface EntityItem {
filename: string;
categories: string[];
}
interface EntityCategories {
[key: string]: string[];
}
export interface StandataConfig {
categories: EntityCategories;
entities: EntityItem[];
}
interface RuntimeData {
standataConfig: StandataConfig;
filesMapByName: object;
}
export declare class Standata {
static runtimeData: RuntimeData;
static getRuntimeDataConfigs(): any[];
entities: EntityItem[];
categories: string[];
protected categoryMap: EntityCategories;
protected lookupTable: {
[key: string]: Set<string>;
};
constructor(config?: StandataConfig);
flattenCategories(separator?: string): string[];
convertTagToCategory(...tags: string[]): string[];
protected createLookupTable(): {
[key: string]: Set<string>;
};
protected loadEntity(filename: string): object | undefined;
protected filterByCategories(...categories: string[]): string[];
findEntitiesByTags(...tags: string[]): object[];
}
export {};
76 changes: 76 additions & 0 deletions dist/js/base.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Standata = void 0;
class Standata {
static getRuntimeDataConfigs() {
return Object.values(this.runtimeData.filesMapByName);
}
constructor(config) {
const ctor = this.constructor;
this.categoryMap = config ? config.categories : ctor.runtimeData.standataConfig.categories;
this.entities = config ? config.entities : ctor.runtimeData.standataConfig.entities;
this.categories = this.flattenCategories();
this.lookupTable = this.createLookupTable();
}
flattenCategories(separator = "/") {
const categories = Object.entries(this.categoryMap)
.flatMap(([type, tags]) => tags.map((t) => `${type}${separator}${t}`))
.sort((a, b) => a.localeCompare(b));
return [...new Set(categories)];
}
convertTagToCategory(...tags) {
return this.categories.filter((c) => tags.some((t) => c.split("/")[1] === t));
}
createLookupTable() {
const lookupTable = {};
// eslint-disable-next-line no-restricted-syntax
for (const entity of this.entities) {
const categories_ = this.convertTagToCategory(...entity.categories);
const { filename } = entity;
// eslint-disable-next-line no-restricted-syntax
for (const category of categories_) {
if (category in lookupTable) {
lookupTable[category].add(filename);
} else {
lookupTable[category] = new Set([filename]);
}
}
}
return lookupTable;
}
loadEntity(filename) {
var _a, _b;
const ctor = this.constructor;
return (_b =
(_a = ctor.runtimeData) === null || _a === void 0 ? void 0 : _a.filesMapByName) ===
null || _b === void 0
? void 0
: _b[filename];
}
filterByCategories(...categories) {
if (!categories.length) {
return [];
}
let filenames = this.entities.map((e) => e.filename);
// eslint-disable-next-line no-restricted-syntax
for (const category of categories) {
filenames = filenames.filter((f) => {
var _a;
return (_a = this.lookupTable[category]) === null || _a === void 0
? void 0
: _a.has(f);
});
}
return filenames;
}
findEntitiesByTags(...tags) {
const categories_ = this.convertTagToCategory(...tags);
const filenames = this.filterByCategories(...categories_) || [];
return filenames.map((f) => this.loadEntity(f)).filter((e) => e !== undefined);
}
}
exports.Standata = Standata;
Standata.runtimeData = {
standataConfig: { entities: [], categories: {} },
filesMapByName: {},
};
1 change: 1 addition & 0 deletions dist/js/cli.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export {};
Loading

0 comments on commit 0281314

Please sign in to comment.