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

Remove last pieces of local Parsoid code #1713

Merged
merged 1 commit into from
Jan 5, 2023
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
10 changes: 1 addition & 9 deletions src/Downloader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,6 @@ interface DownloaderOpts {
uaString: string;
speed: number;
reqTimeout: number;
noLocalParserFallback: boolean;
forceLocalParser: boolean;
optimisationCacheUrl: string;
s3?: S3;
webp: boolean;
Expand Down Expand Up @@ -108,8 +106,6 @@ class Downloader {
private activeRequests = 0;
private maxActiveRequests = 1;
private readonly requestTimeout: number;
private readonly noLocalParserFallback: boolean = false;
private readonly forceLocalParser: boolean = false;
private readonly urlPartCache: KVS<string> = {};
private readonly backoffOptions: BackoffOptions;
private readonly optimisationCacheUrl: string;
Expand All @@ -120,15 +116,13 @@ class Downloader {
public streamRequestOptions: AxiosRequestConfig;


constructor({ mw, uaString, speed, reqTimeout, noLocalParserFallback, forceLocalParser: forceLocalParser, optimisationCacheUrl, s3, webp, backoffOptions }: DownloaderOpts) {
constructor({ mw, uaString, speed, reqTimeout, optimisationCacheUrl, s3, webp, backoffOptions }: DownloaderOpts) {
this.mw = mw;
this.uaString = uaString;
this.speed = speed;
this.maxActiveRequests = speed * 10;
this.requestTimeout = reqTimeout;
this.loginCookie = '';
this.noLocalParserFallback = noLocalParserFallback;
this.forceLocalParser = forceLocalParser;
this.optimisationCacheUrl = optimisationCacheUrl;
this.webp = webp;
this.s3 = s3;
Expand Down Expand Up @@ -231,12 +225,10 @@ class Downloader {
this.baseUrl = this.mwCapabilities.mobileRestApiAvailable ? this.mw.mobileRestApiUrl.href :
this.mwCapabilities.desktopRestApiAvailable ? this.mw.desktopRestApiUrl.href :
this.mwCapabilities.veApiAvailable ? this.mw.veApiUrl.href :
!this.noLocalParserFallback && this.mwCapabilities.apiAvailable ? `http://localhost:6927/${this.mw.webUrl.hostname}/v1/page/mobile-sections/` :
undefined;

this.baseUrlForMainPage = this.mwCapabilities.desktopRestApiAvailable ? this.mw.desktopRestApiUrl.href :
this.mwCapabilities.veApiAvailable ? this.mw.veApiUrl.href :
!this.noLocalParserFallback && this.mwCapabilities.apiAvailable ? `http://localhost:8000/${this.mw.webUrl.hostname}/v3/page/pagebundle/` :
undefined;

logger.log('Base Url: ', this.baseUrl);
Expand Down
4 changes: 0 additions & 4 deletions src/mwoffliner.lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,6 @@ async function execute(argv: any) {
addNamespaces: _addNamespaces,
customZimFavicon: _customZimFavicon,
optimisationCacheUrl,
noLocalParserFallback,
forceLocalParser,
customFlavour
} = argv;

Expand Down Expand Up @@ -186,8 +184,6 @@ async function execute(argv: any) {
uaString: `${config.userAgent} (${adminEmail})`,
speed,
reqTimeout: requestTimeout * 1000 || config.defaults.requestTimeout,
noLocalParserFallback,
forceLocalParser,
optimisationCacheUrl,
s3,
webp,
Expand Down
2 changes: 0 additions & 2 deletions src/parameterList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ export const parameterDescriptions = {
webp: 'Convert all jpeg, png and gif images to webp format',
addNamespaces: 'Force additional namespace (comma separated numbers)',
getCategories: '[WIP] Download category pages',
noLocalParserFallback: 'Don\'t fall back to a local MCS or Parsoid, only use remote APIs',
forceLocalParser: 'Use local Parsoid instance even if remote one available',
osTmpDir: 'Override default operating system temporary directory path environment variable',
customFlavour: 'A custom processor that can filter and process articles (see extensions/*.js)',
optimisationCacheUrl: 'S3 url, including credentials and bucket name',
Expand Down
12 changes: 2 additions & 10 deletions test/unit/downloader.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,12 @@ test('Downloader class', async (t) => {

const cacheDir = `cac/dumps-${Date.now()}/`;
await mkdirPromise(cacheDir);
const downloader = new Downloader({ mw, uaString: `${config.userAgent} (contact@kiwix.org)`, speed: 1, reqTimeout: 1000 * 60, noLocalParserFallback: false, forceLocalParser: false, webp: true, optimisationCacheUrl: '' });
const downloader = new Downloader({ mw, uaString: `${config.userAgent} (contact@kiwix.org)`, speed: 1, reqTimeout: 1000 * 60, webp: true, optimisationCacheUrl: '' });

await mw.getMwMetaData(downloader);
await downloader.checkCapabilities();
await downloader.setBaseUrls();

// const remoteMcsUrl = downloader.mcsUrl;
// const remoteParsoidUrl = downloader.parsoidFallbackUrl;

// const mcsHandle = await downloader.initLocalMcs();

// t.notEqual(remoteMcsUrl, downloader.mcsUrl, 'Initializing local MCS changes mcsUrl');
// t.notEqual(remoteParsoidUrl, downloader.parsoidFallbackUrl, 'Initializing local Parsoid changes parsoidFallbackUrl');

const queryRet = await downloader.query(`?action=query&meta=siteinfo&siprop=statistics&format=json`);
t.ok(!!queryRet, 'downloader.query returns valid JSON');

Expand Down Expand Up @@ -168,7 +160,7 @@ _test('Downloader class with optimisation', async (t) => {
keyId: process.env.KEY_ID_TEST,
secretAccessKey: process.env.SECRET_ACCESS_KEY_TEST,
});
const downloader = new Downloader({ mw, uaString: `${config.userAgent} (contact@kiwix.org)`, speed: 1, reqTimeout: 1000 * 60, noLocalParserFallback: false, forceLocalParser: false, webp: false, optimisationCacheUrl: 'random-string' , s3});
const downloader = new Downloader({ mw, uaString: `${config.userAgent} (contact@kiwix.org)`, speed: 1, reqTimeout: 1000 * 60, webp: false, optimisationCacheUrl: 'random-string' , s3});

await s3.initialise();

Expand Down
4 changes: 2 additions & 2 deletions test/unit/mwApi.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ test('MWApi Article Ids', async (t) => {
getCategories: true,
} as any);

const downloader = new Downloader({ mw, uaString: `${config.userAgent} (contact@kiwix.org)`, speed: 1, reqTimeout: 1000 * 60, noLocalParserFallback: false, forceLocalParser: false, webp: false, optimisationCacheUrl: '' });
const downloader = new Downloader({ mw, uaString: `${config.userAgent} (contact@kiwix.org)`, speed: 1, reqTimeout: 1000 * 60, webp: false, optimisationCacheUrl: '' });

await mw.getMwMetaData(downloader);
await downloader.checkCapabilities();
Expand Down Expand Up @@ -43,7 +43,7 @@ test('MWApi NS', async (t) => {
getCategories: true,
} as any);

const downloader = new Downloader({ mw, uaString: `${config.userAgent} (contact@kiwix.org)`, speed: 1, reqTimeout: 1000 * 60, noLocalParserFallback: false, forceLocalParser: false, webp: false, optimisationCacheUrl: '' });
const downloader = new Downloader({ mw, uaString: `${config.userAgent} (contact@kiwix.org)`, speed: 1, reqTimeout: 1000 * 60, webp: false, optimisationCacheUrl: '' });

await mw.getMwMetaData(downloader);
await downloader.checkCapabilities();
Expand Down
2 changes: 1 addition & 1 deletion test/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export async function setupScrapeClasses({ mwUrl = 'https://en.wikipedia.org', f
base: mwUrl,
} as any);

const downloader = new Downloader({ mw, uaString: `${config.userAgent} (contact@kiwix.org)`, speed: 1, reqTimeout: 1000 * 60, noLocalParserFallback: false, forceLocalParser: false, webp: false, optimisationCacheUrl: '' });
const downloader = new Downloader({ mw, uaString: `${config.userAgent} (contact@kiwix.org)`, speed: 1, reqTimeout: 1000 * 60, webp: false, optimisationCacheUrl: '' });

await mw.getMwMetaData(downloader);
await downloader.checkCapabilities();
Expand Down