Skip to content

Commit

Permalink
Support passing additional parameters to synchronous jobs, update Typ…
Browse files Browse the repository at this point in the history
…eScript declaration
  • Loading branch information
m-mohr committed Jan 17, 2024
1 parent 2bd1bc3 commit 78e8abe
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 15 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Hook to migrate capabilities
- Support for `usage`, `log_level`, `links` in batch jobs and services
- Support for `level` parameter for log requests in batch jobs and services
- Support passing additional parameters to synchronous jobs.

### Removed

Expand All @@ -23,6 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Make the feature / endpoint mapping more robust
- Add missing endpoints to feature / endpoint mapping
- Fix AbortController handling
- Clarify that the `log_level` parameter for jobs, services and sync. processing can be provided via the `additional` parameter

## [2.5.1] - 2022-04-08

Expand Down
24 changes: 15 additions & 9 deletions openeo.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -783,15 +783,17 @@ declare module OpenEO {
*
* @param {Connection} connection - A Connection object representing an established connection to an openEO back-end.
* @param {string} endpoint - The relative endpoint to request the logs from, usually `/jobs/.../logs` or `/services/.../logs` with `...` being the actual job or service id.
* @param {?string} [level=null] Minimum level of logs to return.
*/
constructor(connection: Connection, endpoint: string);
constructor(connection: Connection, endpoint: string, level?: string | null);
/**
* @protected
* @type {Connection}
*/
protected connection: Connection;
endpoint: string;
lastId: string;
level: string;
/**
* Retrieves the next log entries since the last request.
*
Expand Down Expand Up @@ -948,9 +950,10 @@ declare module OpenEO {
/**
* Get logs for the batch job from the back-end.
*
* @param {?string} [level=null] Minimum level of logs to return.
* @returns {Logs}
*/
debugJob(): Logs;
debugJob(level?: string | null): Logs;
/**
* Checks for status changes and new log entries every x seconds.
*
Expand Down Expand Up @@ -1287,9 +1290,10 @@ declare module OpenEO {
/**
* Get logs for the secondary web service from the back-end.
*
* @param {?string} [level=null] Minimum level of logs to return.
* @returns {Logs}
*/
debugService(): Logs;
debugService(level?: string | null): Logs;
/**
* Checks for new log entries every x seconds.
*
Expand Down Expand Up @@ -2276,9 +2280,10 @@ declare module OpenEO {
* @param {?string} [plan=null] - The billing plan to use for this computation.
* @param {?number} [budget=null] - The maximum budget allowed to spend for this computation.
* @param {?AbortController} [abortController=null] - An AbortController object that can be used to cancel the processing request.
* @param {object.<string, *>} [additional={}] - Other parameters to pass for the batch job, e.g. `log_level`.
* @returns {Promise<SyncResult>} - An object with the data and some metadata.
*/
computeResult(process: Process, plan?: string | null, budget?: number | null, abortController?: AbortController | null): Promise<SyncResult>;
computeResult(process: Process, plan?: string | null, budget?: number | null, abortController?: AbortController | null, additional?: object<string, any>): Promise<SyncResult>;
/**
* Executes a process synchronously and downloads to result the given path.
*
Expand Down Expand Up @@ -2315,7 +2320,7 @@ declare module OpenEO {
* @param {?string} [description=null] - A description for the batch job.
* @param {?string} [plan=null] - The billing plan to use for this batch job.
* @param {?number} [budget=null] - The maximum budget allowed to spend for this batch job.
* @param {object.<string, *>} [additional={}] - Proprietary parameters to pass for the batch job.
* @param {object.<string, *>} [additional={}] - Other parameters to pass for the batch job, e.g. `log_level`.
* @returns {Promise<Job>} The stored batch job.
* @throws {Error}
*/
Expand Down Expand Up @@ -2350,7 +2355,7 @@ declare module OpenEO {
* @param {object.<string, *>} [configuration={}] - Configuration parameters to pass to the service.
* @param {?string} [plan=null] - The billing plan to use for this service.
* @param {?number} [budget=null] - The maximum budget allowed to spend for this service.
* @param {object.<string, *>} [additional={}] - Proprietary parameters to pass for the batch job.
* @param {object.<string, *>} [additional={}] - Other parameters to pass for the service, e.g. `log_level`.
* @returns {Promise<Service>} The stored service.
* @throws {Error}
*/
Expand Down Expand Up @@ -2378,20 +2383,21 @@ declare module OpenEO {
/**
* Get the a link with the given rel type.
*
* @protected
* @param {Array.<Link>} links - An array of links.
* @param {string|Array.<string>} rel - Relation type(s) to find.
* @returns {string | null}
* @throws {Error}
*/
getHrefForRel(links: Array<Link>, rel: string | Array<string>): string | null;
protected _getLinkHref(links: Array<Link>, rel: string | Array<string>): string | null;
/**
* Makes all links in the list absolute.
*
* @param {Array.<Link>} links - An array of links.
* @param {?string|AxiosResponse} [base=null] - The base url to use for relative links.
* @param {?string|AxiosResponse} [base=null] - The base url to use for relative links, or an response to derive the url from.
* @returns {Array.<Link>}
*/
makeLinksAbsolute(links: Array<Link>, base?: string | AxiosResponse) : Array.<Link>;
makeLinksAbsolute(links: Array<Link>, base?: (string | AxiosResponse) | null): Array<Link>;
/**
* Sends a GET request.
*
Expand Down
11 changes: 6 additions & 5 deletions src/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -812,15 +812,16 @@ class Connection {
* @param {?string} [plan=null] - The billing plan to use for this computation.
* @param {?number} [budget=null] - The maximum budget allowed to spend for this computation.
* @param {?AbortController} [abortController=null] - An AbortController object that can be used to cancel the processing request.
* @param {object.<string, *>} [additional={}] - Other parameters to pass for the batch job, e.g. `log_level`.
* @returns {Promise<SyncResult>} - An object with the data and some metadata.
*/
async computeResult(process, plan = null, budget = null, abortController = null) {
async computeResult(process, plan = null, budget = null, abortController = null, additional = {}) {
let requestBody = this._normalizeUserProcess(
process,
{
Object.assign({}, additional, {
plan: plan,
budget: budget
}
})
);
let response = await this._post('/result', requestBody, Environment.getResponseType(), abortController);
let syncResult = {
Expand Down Expand Up @@ -911,7 +912,7 @@ class Connection {
* @param {?string} [description=null] - A description for the batch job.
* @param {?string} [plan=null] - The billing plan to use for this batch job.
* @param {?number} [budget=null] - The maximum budget allowed to spend for this batch job.
* @param {object.<string, *>} [additional={}] - Proprietary parameters to pass for the batch job.
* @param {object.<string, *>} [additional={}] - Other parameters to pass for the batch job, e.g. `log_level`.
* @returns {Promise<Job>} The stored batch job.
* @throws {Error}
*/
Expand Down Expand Up @@ -981,7 +982,7 @@ class Connection {
* @param {object.<string, *>} [configuration={}] - Configuration parameters to pass to the service.
* @param {?string} [plan=null] - The billing plan to use for this service.
* @param {?number} [budget=null] - The maximum budget allowed to spend for this service.
* @param {object.<string, *>} [additional={}] - Proprietary parameters to pass for the batch job.
* @param {object.<string, *>} [additional={}] - Other parameters to pass for the service, e.g. `log_level`.
* @returns {Promise<Service>} The stored service.
* @throws {Error}
*/
Expand Down
1 change: 0 additions & 1 deletion src/logs.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ class Logs {
*
* @async
* @param {number} limit - The number of log entries to retrieve per request, as integer.
* @param {number} level - The number of log entries to retrieve per request, as integer.
* @returns {Promise<Array.<Log>>}
*/
async nextLogs(limit = null) {
Expand Down

0 comments on commit 78e8abe

Please sign in to comment.