Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make ncores in workfow rewrite configurable #69

Merged
merged 1 commit into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ BARTENDER_PRIVATE_KEY=private_key.pem
# See docs/auth.md#session how generate a better secret
SESSION_SECRET=<please replace with a better secret>
# For social login see docs/auth.md
# See docs/rewriter.md how to configure the workflow rewriting
HADDOCK3_NCORES = 6
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Uses
- [bartender](https://github.com/i-VRESSE/bartender) for job execution.
- [workflow-builder](https://github.com/i-VRESSE/workflow-builder) to construct a Haddock3 workflow config file.
- [haddock3](https://github.com/haddocking/haddock3) to compute
- [haddock3-analysis-components](https://github.com/i-VRESSE/haddock3-analysis-components) for analysis components.

```mermaid
sequenceDiagram
Expand All @@ -33,6 +34,7 @@ npm install
Configuration of the web application is done via `.env` file or environment variables.
For configuration of authentication & authorization see [docs/auth.md](docs/auth.md).
For configuration of job submission see [docs/bartender.md#configuration](docs/bartender.md#configuration).
For configuration of how to rewrite the submitted workflow file see [docs/reewite.md](docs/reewite.md).
Use [.env.example](./.env.example) as a template:

```shell
Expand Down
29 changes: 28 additions & 1 deletion app/models/applicaton.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,14 @@ async function rewriteConfig(config_body: string) {
table.mode = "local";
table.postprocess = true;
table.clean = true;
delete table.ncores;

const haddock3_ncores = getNCores();
if (haddock3_ncores > 0) {
table.ncores = haddock3_ncores;
} else {
delete table.ncores;
}
delete table.max_cpus;
delete table.batch_type;
delete table.queue;
delete table.queue_limit;
Expand All @@ -76,6 +83,26 @@ async function rewriteConfig(config_body: string) {
});
}

/**
*
* @returns Number of cores to use for haddock3. 0 means use default.
*/
function getNCores() {
let haddock3_ncores = 0;
if (
process.env.HADDOCK3_NCORES !== undefined &&
process.env.HADDOCK3_NCORES !== ""
) {
haddock3_ncores = parseInt(process.env.HADDOCK3_NCORES);
if (isNaN(haddock3_ncores)) {
throw new Error(
`HADDOCK3_NCORES env var is not a number: ${process.env.HADDOCK3_NCORES}`
);
}
}
return haddock3_ncores;
}

export async function rewriteConfigInArchive(upload: Blob) {
const zip = new JSZip();
// Tried to give upload blob directly to loadAsync, but failed with
Expand Down
11 changes: 11 additions & 0 deletions docs/rewrite.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Workflow rewrite

You can submit a workflow to the webapp that can contain any parameter that haddock3 cli accepts.
However we do not want a user to tell the webapp for example which run dir, queue to use, which cns executable, etc.
The webapp should control most of the [global parameters](https://github.com/i-VRESSE/workflow-builder/blob/main/packages/haddock3_catalog/public/catalog/haddock3.guru.yaml) except molecules parameter and preprocess parameter.

Currently the submitted workflow is rewritten at [app/models/applicaton.server.ts](app/models/applicaton.server.ts) to defaults fit for bartender job service.

The following parameters can be rewritten with environment variables:

- Number of CPU cores (ncores) with `HADDOCK3_NCORES` environment variable. If not set uses haddock3 default.