-
Notifications
You must be signed in to change notification settings - Fork 4
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
refactor: Specify common types TDE-1030 #849
Conversation
const obj = await fsa.read(config); | ||
if (config.endsWith('.gz') || isGzip(obj)) { | ||
async function readConfig(config: URL): Promise<ConfigBundled> { | ||
const obj = await fsa.read(config.href); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
its not safe to use .href
here. If its a file url it has to be converted with path.fileURLToPath
.
does fsa.read
not accept a URL? would imply fsa
is out of date?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
its not safe to use
.href
here. If its a file url it has to be converted withpath.fileURLToPath
.
I'd rather upgrade fsa, but:
does
fsa.read
not accept a URL? would implyfsa
is out of date?
Yep; that PR needs a bunch of fixes, though.
if (baseFile) { | ||
target = fsa.joinAll(targetPath, transformFunc ? transformFunc(baseFile) : baseFile); | ||
target = new URL(fsa.joinAll(targetUrl.href, transformFunc ? transformFunc(baseFile) : baseFile)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
joinAll
does a very similar job to new URL(input, base)
in most use cases it should be a direct swap.
I believe the one caveat is joinAll("foo.com/bar", "baz")
would make "foo.com/bar/baz" where as new URL("baz", "foo.com/bar")
would make "foo.com/baz"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, new URL('sub-path', 's3://bucket/path').href === "s3://bucket/sub-path"
. But I don't know what to do about that info. I would expect most of our base URLs to be arbitrary non-root ones, in which case new URL(input, base)
would not do what we want. Which means joinAll
is the safer alternative. Or are you saying the base URLs will always end with a slash, so that both solutions do the same thing?
We also have a normaliseHref
in src/commands/stac-validate/stac.validate.ts
and tryParseUrl
in src/commands/common.ts
which should probably be removed.
Bumps the chunkd group with 3 updates: [@chunkd/fs](https://github.com/blacha/chunkd/tree/HEAD/packages/fs), [@cogeotiff/core](https://github.com/blacha/cogeotiff/tree/HEAD/packages/core) and [@chunkd/source-memory](https://github.com/blacha/chunkd/tree/HEAD/packages/source-memory). Updates `@chunkd/fs` from 10.0.9 to 11.2.0 - [Release notes](https://github.com/blacha/chunkd/releases) - [Changelog](https://github.com/blacha/chunkd/blob/master/packages/fs/CHANGELOG.md) - [Commits](https://github.com/blacha/chunkd/commits/fs-v11.2.0/packages/fs) Updates `@cogeotiff/core` from 8.1.1 to 9.0.3 - [Release notes](https://github.com/blacha/cogeotiff/releases) - [Changelog](https://github.com/blacha/cogeotiff/blob/master/packages/core/CHANGELOG.md) - [Commits](https://github.com/blacha/cogeotiff/commits/cli-v9.0.3/packages/core) Updates `@chunkd/source-memory` from 10.1.0 to 11.0.2 - [Release notes](https://github.com/blacha/chunkd/releases) - [Changelog](https://github.com/blacha/chunkd/blob/master/packages/source-memory/CHANGELOG.md) - [Commits](https://github.com/blacha/chunkd/commits/fs-v11.0.2/packages/source-memory) --- updated-dependencies: - dependency-name: "@chunkd/fs" dependency-type: direct:production update-type: version-update:semver-major dependency-group: chunkd - dependency-name: "@cogeotiff/core" dependency-type: direct:production update-type: version-update:semver-major dependency-group: chunkd - dependency-name: "@chunkd/source-memory" dependency-type: direct:development update-type: version-update:semver-major dependency-group: chunkd ... Signed-off-by: dependabot[bot] <support@github.com>
src/commands/copy/copy-rpc.ts
Outdated
@@ -6,7 +6,7 @@ export interface CopyContractArgs { | |||
/** Copy ID for tracing */ | |||
id: string; | |||
/** List of files that need to be copied */ | |||
manifest: { source: string; target: string }[]; | |||
manifest: { source: URL; target: URL }[]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can worker threads actually pass URLS? I thought everything was meant to be a POJO for passing around?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume you mean either JSON or JS object, not "Plain old Java object". I have no idea how WorkerRpc
works; I guess since you ask we don't have tests for this message passing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
worker_threads
are a mechanisim of using small scripts to add more threads to do processing, they are limited to posting messages to/from the thread using a rpc type mechanisim, WorkerRpc
wraps the posting so it is somewhat typesafe.
I am not sure we can pass a URL between threads as its not really a easily searliazable thing, just like you cant pass a date but you can pass a ISO string.
Should not have been commented.
`new URL` can take URL as the second argument, so we don't need to do the `.href` lookup.
They might not be able to deal with an `URL`.
Co-authored-by: Blayne Chard <bchard@linz.govt.nz>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These issues could have prevented the commands from running, it is slightly concerning that they are this deep in the pull request chain and I have likely missed other spots where things are broken.
Have you run any of the commands before making this PR?
logger.info({ config }, 'MapSheet:LoadConfig'); | ||
const configJson = await readConfig(config); | ||
const mem = ConfigProviderMemory.fromJson(configJson); | ||
|
||
const rest = fgb.deserialize(buf) as FeatureCollection; | ||
const featuresWritePromise = fsa.write('features.json', JSON.stringify(rest)); | ||
const featuresWritePromise = fsa.write(new URL(fsa.toUrl('./features.json').href), JSON.stringify(rest)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const featuresWritePromise = fsa.write(new URL(fsa.toUrl('./features.json').href), JSON.stringify(rest)); | |
const featuresWritePromise = fsa.write(fsa.toUrl('./features.json'), JSON.stringify(rest)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was using the wrong interpreter; please ignore the deleted comment.
No, because making heaps of manual smoke tests for each refactor is tedious, error-prone, and slow. If it's worth testing we should have automated tests for it. |
Motivation
Strengthen type limitations to make it easier to understand where a "string" is actually a URL and where it's really a local path.
Checklist
Refactor; none of the checklist is applicable.