repo_name stringlengths 1 62 | dataset stringclasses 1
value | lang stringclasses 11
values | pr_id int64 1 20.1k | owner stringlengths 2 34 | reviewer stringlengths 2 39 | diff_hunk stringlengths 15 262k | code_review_comment stringlengths 1 99.6k |
|---|---|---|---|---|---|---|---|
swift-openapi-generator | github_2023 | others | 140 | apple | czechboy0 | @@ -231,6 +231,46 @@ final class Test_Server: XCTestCase {
)
}
+
+ func testCreatePet_withIncorrectContentType() async throws {
+ client = .init(
+ createPetBlock: { input in
+ return .created(
+ .init(
+ headers: .init(
+... | ```suggestion
XCTFail("The handler should not have been called")
```
This should not be called, nor return, so no need to construct a response here, just assert that it's not called. |
swift-openapi-generator | github_2023 | others | 140 | apple | czechboy0 | @@ -231,6 +231,35 @@ final class Test_Server: XCTestCase {
)
}
+
+ func testCreatePet_withIncorrectContentType() async throws {
+ client = .init(
+ createPetBlock: { input in
+ XCTFail("The handler should not have been called") | The CI is complaining about this, we need to return Never here, for example like this.
```suggestion
XCTFail("The handler should not have been called")
fatalError("Unreachable")
```
|
swift-openapi-generator | github_2023 | others | 123 | apple | czechboy0 | @@ -16,6 +16,30 @@ import ArgumentParser
import _OpenAPIGeneratorCore
extension _Tool {
+
+ /// A structure that defines ANSI escape codes for different colors in the terminal output.
+ ///
+ /// You can use these codes to change the color of the text printed by the `print` function or other methods th... | Can you file adding support for command colors into a separate issue? I'd welcome command colors, but:
- we should add them to all the commands consistently
- detect when we're not in an interactive session and skip colors, so that they don't pollute text logs
- discuss how to use the colors to make information easy... |
swift-openapi-generator | github_2023 | others | 123 | apple | czechboy0 | @@ -67,44 +99,69 @@ extension _Tool {
/// - config: A set of configuration values for the generator.
/// - outputFilePath: The directory to which the generator writes
/// the generated Swift files.
+ /// - isDryRun: A Boolean value that indicates whether this invocation should
+ /// be a ... | We can continue printing this line, it'd be useful to still see if the contents of this file changed or not, even in dry run. |
swift-openapi-generator | github_2023 | others | 123 | apple | czechboy0 | @@ -42,20 +44,25 @@ extension _Tool {
let filePathForMode: (GeneratorMode) -> URL = { mode in
outputDirectory.appendingPathComponent(mode.outputFileName)
}
+ if isDryRun {
+ print("--------------------------------")
+ print("Dry run mode: No files will be crea... | I don't think we need it, as it's already included in the launch summary that it's dry run. |
swift-openapi-generator | github_2023 | others | 123 | apple | czechboy0 | @@ -67,44 +74,66 @@ extension _Tool {
/// - config: A set of configuration values for the generator.
/// - outputFilePath: The directory to which the generator writes
/// the generated Swift files.
+ /// - isDryRun: A Boolean value that indicates whether this invocation should
+ /// be a ... | This method shouldn't print anything, just return whether the file contents have changed. Let's keep the printing in the caller, though. |
swift-openapi-generator | github_2023 | others | 123 | apple | czechboy0 | @@ -67,45 +70,72 @@ extension _Tool {
/// - config: A set of configuration values for the generator.
/// - outputFilePath: The directory to which the generator writes
/// the generated Swift files.
+ /// - isDryRun: A Boolean value that indicates whether this invocation should
+ /// be a ... | I think we can get rid of this print, the summary below is enough to know what the generator did for this file. |
swift-openapi-generator | github_2023 | others | 123 | apple | simonjbeaumont | @@ -104,8 +118,12 @@ extension _Tool {
didChange = true
}
if didChange {
- try data.write(to: path)
+ print("File \(path.lastPathComponent) will be overwritten.")
+ if !isDryRun {
+ try data.write(to: path)
+ }
+ } else {
+... | At this stage, I'm going to approve the PR because it does what it set out to do.
However, IMO the code has become a bit too branchy. On inspection, I don't think that's really because of this PR.
We could also make use of some `guards` to early-return and make the code more linear.
Finally, this function al... |
swift-openapi-generator | github_2023 | others | 123 | apple | czechboy0 | @@ -48,10 +48,17 @@ struct _GenerateCommand: AsyncParsableCommand {
)
var isPluginInvocation: Bool = false
+ @Flag(
+ help:
+ "Simulate the command and print the operations, without actually affecting the file system."
+ )
+ var isDryRun: Bool = false | Oh sorry for the late request, could we just make it `--dry-run`? At the moment, the name would be `--is-dry-run`, which feels like a question rather than an instruction.
I believe there's a parameter on the Option property wrapper customize the CLI name, which means you won't need to change the property name itself. |
swift-openapi-generator | github_2023 | others | 103 | apple | czechboy0 | @@ -0,0 +1,351 @@
+//===----------------------------------------------------------------------===//
+//
+// This source file is part of the SwiftOpenAPIGenerator open source project
+//
+// Copyright (c) 2023 Apple Inc. and the SwiftOpenAPIGenerator project authors
+// Licensed under Apache License v2.0
+//
+// See LIC... | Overall looks great, just one idea - to avoid having to duplicate the openapi version, info, and paths keys in every snippet, could we have them be added by default, unless specified explicitly? That way you can only specify the important part of the OpenAPI doc in each test, without duplicating the unimportant parts.
... |
swift-openapi-generator | github_2023 | others | 103 | apple | czechboy0 | @@ -0,0 +1,321 @@
+//===----------------------------------------------------------------------===//
+//
+// This source file is part of the SwiftOpenAPIGenerator open source project
+//
+// Copyright (c) 2023 Apple Inc. and the SwiftOpenAPIGenerator project authors
+// Licensed under Apache License v2.0
+//
+// See LIC... | Yeah these three methods are a great way to test this, IMO. I'd be in favor of fleshing this out. 👍 |
swift-openapi-generator | github_2023 | others | 103 | apple | czechboy0 | @@ -0,0 +1,777 @@
+//===----------------------------------------------------------------------===//
+//
+// This source file is part of the SwiftOpenAPIGenerator open source project
+//
+// Copyright (c) 2023 Apple Inc. and the SwiftOpenAPIGenerator project authors
+// Licensed under Apache License v2.0
+//
+// See LIC... | I see here we have 4 spaces and 2 in the previous test, is that intentional? |
swift-openapi-generator | github_2023 | others | 103 | apple | czechboy0 | @@ -0,0 +1,777 @@
+//===----------------------------------------------------------------------===//
+//
+// This source file is part of the SwiftOpenAPIGenerator open source project
+//
+// Copyright (c) 2023 Apple Inc. and the SwiftOpenAPIGenerator project authors
+// Licensed under Apache License v2.0
+//
+// See LIC... | I wonder if we should make SnippetBasedReferenceTests a superclass and put tests into a few smaller subclasses. That'd also keep the utilities at the end of this file out of the file with actual test cases.
But that's part of expected organic growth, so I'm fine with this not being changed in this PR, just wondering i... |
swift-openapi-generator | github_2023 | others | 92 | apple | czechboy0 | @@ -69,7 +69,7 @@ extension FileTranslator {
guard let comment = blueprint.comment else {
return structDecl | Seems we won't add the deprecation annotation in the else branch of this guard? |
swift-openapi-generator | github_2023 | others | 92 | apple | czechboy0 | @@ -103,6 +106,9 @@ struct PropertyBlueprint {
/// A documentation comment for the property.
var comment: Comment? = nil
+ /// Whether the type should be annotated as deprecated. | ```suggestion
/// Whether the property should be annotated as deprecated.
```
|
swift-openapi-generator | github_2023 | others | 92 | apple | czechboy0 | @@ -370,6 +372,17 @@ components:
- $ref: '#/components/schemas/MessagedExercise'
discriminator:
propertyName: kind
+ DeprecatedObject:
+ deprecated: true
+ type: object
+ properties: {}
+ additionalProperties: false | Did you explicitly turn off additional properties on purpose? You could just omit this field, and get the default behavior of an even smaller struct. |
swift-openapi-generator | github_2023 | others | 92 | apple | michalsrutek | @@ -11,7 +11,14 @@ services:
test:
image: *image
environment:
- - WARN_AS_ERROR_ARG=-Xswiftc -warnings-as-errors
+ # Because OpenAPI supports deprecation, the generated code could include
+ # deprecated symbols, which will produce warnings.
+ #
+ # We'll desable -warnings-as-errors... | typo in `desable` - should be `disable` |
swift-openapi-generator | github_2023 | others | 111 | apple | czechboy0 | @@ -56,7 +56,7 @@ let package = Package(
),
.package(
url: "https://github.com/jpsim/Yams.git",
- from: "4.0.0"
+ from: "5.0.0" | Can we change to a range that's 4..<6? I've seen that done in projects, allows adopters to be using either major version. Just requires that we're using API present in both. |
swift-openapi-generator | github_2023 | others | 81 | apple | czechboy0 | @@ -116,8 +117,7 @@ let package = Package(
.executableTarget(
name: "swift-openapi-generator",
dependencies: [
- "_OpenAPIGeneratorCore",
- .product(name: "ArgumentParser", package: "swift-argument-parser"),
+ "_OpenAPIGeneratorCore" | It'd be great to avoid making the library depend on swift-argument-parser, see comments below how we should be able to remove it again. |
swift-openapi-generator | github_2023 | others | 81 | apple | czechboy0 | @@ -37,6 +37,12 @@ public struct Diagnostic: Error, Codable {
/// A user-friendly description of the diagnostic.
public var message: String
+ /// The absolute path to a specific source file that triggered the diagnostic.
+ public var absoluteFilePath: URL?
+
+ /// The line number within the specifi... | Since we'll either always have location, or not have location, let's represent it as
```swift
struct Diagnostic {
//...
struct Location {
var filePath: String
var lineNumber: Int
}
var location: Location?
}
``` |
swift-openapi-generator | github_2023 | others | 81 | apple | czechboy0 | @@ -101,8 +107,20 @@ extension Diagnostic.Severity: CustomStringConvertible {
extension Diagnostic: CustomStringConvertible {
public var description: String {
+ var prefix = ""
+ if let filePath = absoluteFilePath {
+ if #available(macOS 13.0, *) {
+ prefix = "\(filePath.... | Just use this codepath that works on all platforms, no need to branch out to the new API on newer OS versions. |
swift-openapi-generator | github_2023 | others | 81 | apple | czechboy0 | @@ -58,9 +65,63 @@ struct YamsParser: ParserProtocol {
throw OpenAPIVersionError(versionString: "openapi: \(openAPIVersion)")
}
- return try decoder.decode(
- OpenAPI.Document.self,
- from: input.contents
- )
+ do {
+ return try decoder.decod... | ```suggestion
private func checkParsingError(
```
A naming suggestion - let's use camelCase, and suggested slightly different phrase. |
swift-openapi-generator | github_2023 | others | 81 | apple | czechboy0 | @@ -58,9 +65,63 @@ struct YamsParser: ParserProtocol {
throw OpenAPIVersionError(versionString: "openapi: \(openAPIVersion)")
}
- return try decoder.decode(
- OpenAPI.Document.self,
- from: input.contents
- )
+ do {
+ return try decoder.decod... | Can you add `location: Location? = nil` to the convenience initializer so that we can create the Diagnostic in one step here, instead of modifying it after creation? |
swift-openapi-generator | github_2023 | others | 81 | apple | czechboy0 | @@ -58,9 +65,63 @@ struct YamsParser: ParserProtocol {
throw OpenAPIVersionError(versionString: "openapi: \(openAPIVersion)")
}
- return try decoder.decode(
- OpenAPI.Document.self,
- from: input.contents
- )
+ do {
+ return try decoder.decod... | The Diagnostic itself conforms to error, so you can emit it into the DiagnosticCollector, and then also throw it. This will allow us to drop the dependency on swift-argument-parser. |
swift-openapi-generator | github_2023 | others | 81 | apple | czechboy0 | @@ -58,9 +65,63 @@ struct YamsParser: ParserProtocol {
throw OpenAPIVersionError(versionString: "openapi: \(openAPIVersion)")
}
- return try decoder.decode(
- OpenAPI.Document.self,
- from: input.contents
- )
+ do {
+ return try decoder.decod... | ```suggestion
private func throwParsingError(
```
CamelCase, and please add a documentation comment for this method. |
swift-openapi-generator | github_2023 | others | 81 | apple | czechboy0 | @@ -25,24 +26,151 @@ final class Test_YamsParser: Test_Core {
XCTAssertThrowsError(try _test("2.0"))
}
- func _test(_ openAPIVersionString: String) throws -> ParsedOpenAPIRepresentation {
+ private func _test(_ openAPIVersionString: String) throws -> ParsedOpenAPIRepresentation {
+ try _tes... | Here, you'd check for the Diagnostic being thrown, after you remove the swift-argument-parser dependency. |
swift-openapi-generator | github_2023 | others | 81 | apple | czechboy0 | @@ -65,13 +66,19 @@ extension _GenerateOptions {
- Additional imports: \(resolvedAdditionalImports.isEmpty ? "<none>" : resolvedAdditionalImports.joined(separator: ", "))
"""
)
- try _Tool.runGenerator(
- doc: doc,
- configs: configs,
- isPlugin... | Oh cool, does this avoid the duplication? |
swift-openapi-generator | github_2023 | others | 81 | apple | czechboy0 | @@ -30,37 +30,84 @@ struct YamsParser: ParserProtocol {
var openapi: String?
}
- struct OpenAPIVersionError: Error, CustomStringConvertible, LocalizedError {
- var versionString: String
- var description: String {
- "Unsupported document version: \(ver... | Please also document parameters |
swift-openapi-generator | github_2023 | others | 81 | apple | czechboy0 | @@ -30,37 +30,84 @@ struct YamsParser: ParserProtocol {
var openapi: String?
}
- struct OpenAPIVersionError: Error, CustomStringConvertible, LocalizedError {
- var versionString: String
- var description: String {
- "Unsupported document version: \(ver... | Please also document parameters |
swift-openapi-generator | github_2023 | others | 81 | apple | czechboy0 | @@ -30,37 +30,84 @@ struct YamsParser: ParserProtocol {
var openapi: String?
}
- struct OpenAPIVersionError: Error, CustomStringConvertible, LocalizedError {
- var versionString: String
- var description: String {
- "Unsupported document version: \(ver... | Please also document parameters |
swift-openapi-generator | github_2023 | others | 81 | apple | czechboy0 | @@ -85,11 +94,16 @@ public struct Diagnostic: Error, Codable {
public static func unsupported( | Please add documentation for the location parameter |
swift-openapi-generator | github_2023 | others | 81 | apple | czechboy0 | @@ -67,9 +75,10 @@ public struct Diagnostic: Error, Codable {
/// - Returns: An error diagnostic. | Please add documentation for the location parameter |
swift-openapi-generator | github_2023 | others | 81 | apple | czechboy0 | @@ -54,9 +61,10 @@ public struct Diagnostic: Error, Codable {
/// - Returns: A warning diagnostic.
public static func warning( | Please add documentation for the location parameter |
swift-openapi-generator | github_2023 | others | 81 | apple | czechboy0 | @@ -37,12 +37,19 @@ public struct Diagnostic: Error, Codable {
/// A user-friendly description of the diagnostic.
public var message: String
+ /// The absolute path to a specific source file and optional line number within that file that triggered the diagnostic.
+ public struct Location: Codable {
+ ... | Please add documentation for the properties inside Location, and the location property itself. |
swift-openapi-generator | github_2023 | others | 87 | apple | denil-ct | @@ -0,0 +1,5 @@
+
+// Details: https://github.com/apple/swift-openapi-generator/issues/86
+#if os(iOS) || os(tvOS) || os(watchOS)
+#error("Running the generator tool itself is not supported on iOS, tvOS, and watchOS. Check that your app is not linking the generator directly. For details, check out: https://github.com/a... | `The generator tool cannot run on iOS, tvOS, or watchOS. Make sure your app does not link against the generator directly. See https://github.com/apple/swift-openapi-generator/issues/86 for details.`
I feel like this removes redundant words from the first sentence and on the second, it adds a more polite and imperati... |
swift-openapi-generator | github_2023 | others | 87 | apple | simonjbeaumont | @@ -0,0 +1,18 @@
+//===----------------------------------------------------------------------===//
+//
+// This source file is part of the SwiftOpenAPIGenerator open source project
+//
+// Copyright (c) 2023 Apple Inc. and the SwiftOpenAPIGenerator project authors
+// Licensed under Apache License v2.0
+//
+// See LICE... | I think this is what we want. Especially with upcoming `visionOS`.
```suggestion
#if !(os(macOS) || os(Linux))
``` |
swift-openapi-generator | github_2023 | others | 87 | apple | simonjbeaumont | @@ -0,0 +1,18 @@
+//===----------------------------------------------------------------------===//
+//
+// This source file is part of the SwiftOpenAPIGenerator open source project
+//
+// Copyright (c) 2023 Apple Inc. and the SwiftOpenAPIGenerator project authors
+// Licensed under Apache License v2.0
+//
+// See LICE... | I'd rather us carry informative comments _here_ than link out to Github.
```suggestion
// Emit a compiler error if this library is linked with a target in an adopter project.
``` |
swift-openapi-generator | github_2023 | others | 87 | apple | simonjbeaumont | @@ -0,0 +1,18 @@
+//===----------------------------------------------------------------------===//
+//
+// This source file is part of the SwiftOpenAPIGenerator open source project
+//
+// Copyright (c) 2023 Apple Inc. and the SwiftOpenAPIGenerator project authors
+// Licensed under Apache License v2.0
+//
+// See LICE... | ```suggestion
#error("_OpenAPIGeneratorCore is only to be used by swift-openapi-generator itself—your target should not link this library directly.")
``` |
swift-openapi-generator | github_2023 | others | 87 | apple | simonjbeaumont | @@ -17,7 +17,13 @@ import PackageDescription
let package = Package(
name: "swift-openapi-generator",
platforms: [
- .macOS(.v10_15)
+ .macOS(.v10_15),
+
+ // The platforms below are not currently supported for running the
+ // generator itself (only the generated code), they are h... | I'm really not a fan of us having to do this and would rather us consider removing `_OpenAPIGeneratorCore` from `products`.
If we do have to do it, we can make use of string version numbers for unreasonably high version numbers, e.g.
```suggestion
.macOS(.v10_15),
// The platforms below are no... |
swift-openapi-generator | github_2023 | others | 88 | apple | simonjbeaumont | @@ -217,5 +217,7 @@ fileprivate extension String {
"Array",
"Type",
"type",
+ "Protocol", | Do we need this one? This works fine:
```swift
let Protocol = 1
print(Protocol) // prints 1
``` |
swift-openapi-generator | github_2023 | others | 88 | apple | simonjbeaumont | @@ -217,5 +217,7 @@ fileprivate extension String {
"Array",
"Type",
"type",
+ "Protocol",
+ "await", | This one is fun... TIL this fails only at use, but not on the variable declaration:
```swift
let await = 1 // this is fine
print(await) // this is the problem
``` |
swift-openapi-generator | github_2023 | others | 85 | apple | czechboy0 | @@ -38,7 +38,7 @@ The generated code relies on functionality in the runtime library that is not pa
To use this functionality, use an SPI import:
-```swift
+``` | Why the removal? I still think it's good to have them, so that previewing the markdown files outside of docc still gives you a nice experience. |
swift-openapi-generator | github_2023 | others | 77 | apple | czechboy0 | @@ -47,14 +47,14 @@ struct SwiftOpenAPIGeneratorPlugin {
targetName: String
) throws -> [Command] {
let inputFiles = sourceFiles
- guard let config = inputFiles.first(where: { $0.path.lastComponent == "openapi-generator-config.yaml" })?.path
+ guard let config = inputFiles.first(whe... | Since we're going from 1 to many here, could you refactor the closure to be similar to how we check for multiple names below, for the OpenAPI doc name? To avoid repeating the `$0.path.lastComponent`. |
swift-openapi-generator | github_2023 | others | 77 | apple | czechboy0 | @@ -28,10 +28,10 @@ struct SwiftOpenAPIGeneratorPlugin {
"Incompatible target called '\(targetName)'. Only Swift source targets can be used with the Swift OpenAPI generator plugin."
case .noConfigFound(let targetName):
return
- "No config found in th... | Ah, good call updating the docs. One more to update: https://swiftpackageindex.com/apple/swift-openapi-generator/0.1.2/documentation/swift-openapi-generator/configuring-the-generator |
swift-openapi-generator | github_2023 | others | 77 | apple | czechboy0 | @@ -28,17 +28,20 @@ struct SwiftOpenAPIGeneratorPlugin {
"Incompatible target called '\(targetName)'. Only Swift source targets can be used with the Swift OpenAPI generator plugin."
case .noConfigFound(let targetName):
return
- "No config found in th... | 👏 |
swift-openapi-generator | github_2023 | others | 77 | apple | simonjbeaumont | @@ -47,21 +50,14 @@ struct SwiftOpenAPIGeneratorPlugin {
targetName: String
) throws -> [Command] {
let inputFiles = sourceFiles
- guard let config = inputFiles.first(where: { $0.path.lastComponent == "openapi-generator-config.yaml" })?.path
- else {
+ guard let config = inpu... | Should we consider what happens when there are multiple files here with different extensions.
Should we throw an error?
Similar question about the config file. Be nice to have some clear semantics, even if it’s explicitly disallowed.
//cc @czechboy0 |
swift-openapi-generator | github_2023 | others | 77 | apple | czechboy0 | @@ -28,10 +30,16 @@ struct SwiftOpenAPIGeneratorPlugin {
"Incompatible target called '\(targetName)'. Only Swift source targets can be used with the Swift OpenAPI generator plugin."
case .noConfigFound(let targetName):
return
- "No config found in th... | ```suggestion
"Multiple config files found in the target named '\(targetName)', but exactly one is required. Found \(files.map(\.description).joined(separator: " "))."
``` |
swift-openapi-generator | github_2023 | others | 77 | apple | czechboy0 | @@ -28,10 +30,16 @@ struct SwiftOpenAPIGeneratorPlugin {
"Incompatible target called '\(targetName)'. Only Swift source targets can be used with the Swift OpenAPI generator plugin."
case .noConfigFound(let targetName):
return
- "No config found in th... | ```suggestion
"Multiple OpenAPI documents found in the target named '\(targetName)', but exactly one is required. Found \(files.map(\.description).joined(separator: " "))."
``` |
swift-openapi-generator | github_2023 | others | 77 | apple | czechboy0 | @@ -40,28 +48,28 @@ struct SwiftOpenAPIGeneratorPlugin {
}
}
+ private var supportedConfigFiles: Set<String> { Set(["yaml", "yml"].map { "openapi-generator-config." + $0 }) }
+ private var supportedDocFiles: Set<String> { Set(["yaml", "yml", "json"].map { "openapi." + $0 }) }
+
func createBui... | I think this (and similar for the docs below) needs a bit of work, to cover the following conditions:
- no match found, throw `noConfigFound`
- more than 1 match found, throw `multipleConfigsFound` |
swift-openapi-generator | github_2023 | others | 77 | apple | czechboy0 | @@ -37,7 +37,7 @@ if [ "${SWIFT_FORMAT_RC}" -ne 0 ]; then
To fix, run the following command:
- % swift-format format --parallel --recursive --in-place Examples IntegrationTests Plugins Sources Tests
+ % swift-format format --parallel --recursive --in-place Examples IntegrationTest Plugins Sources Tests | Oh, great catch, thanks for fixing as well. |
swift-openapi-generator | github_2023 | others | 69 | apple | czechboy0 | @@ -344,7 +344,7 @@ final class Test_Client: XCTestCase {
func testProbe_204() async throws {
transport = .init { request, baseURL, operationID in
XCTAssertEqual(operationID, "probe")
- XCTAssertEqual(request.path, "/probe")
+ XCTAssertEqual(request.path, "/probe/") | Great, thanks for updating the `PetstoreConsumerTests` target as well – this is the important bit that verifies that the trailing slash is actually passed to the transport, and not stripped between OpenAPIKit and the generated code. |
swift-openapi-generator | github_2023 | others | 74 | apple | czechboy0 | @@ -44,3 +44,8 @@ struct TypedSchemaContent {
typeUsage ?? TypeName.valueContainer.asUsage
}
}
+
+/// An unresolved OpenAPI schema.
+///
+/// Can be either a reference or an inline schema.
+typealias UnresolvedSchema = Either<JSONReference<JSONSchema>, JSONSchema> | I think the location is fine. |
swift-openapi-generator | github_2023 | others | 74 | apple | czechboy0 | @@ -113,3 +113,11 @@ extension FileTranslator {
)
}
}
+
+/// An unresolved OpenAPI request.
+///
+/// Can be either a reference or an inline request.
+typealias UnresolvedRequest = Either<JSONReference<OpenAPI.Request>, OpenAPI.Request>
+
+/// A resolved OpenAPI request.
+typealias ResolvedRequest = Open... | I think I agree - can you get rid of all the Resolved* typealiases? They seem like an unnecessary layer of indirection. |
swift-openapi-generator | github_2023 | others | 74 | apple | simonjbeaumont | @@ -228,9 +228,6 @@ extension FileTranslator {
/// Can be either a reference or an inline parameter.
typealias UnresolvedParameter = Either<JSONReference<OpenAPI.Parameter>, OpenAPI.Parameter>
-/// A resolved OpenAPI parameter.
-typealias ResolvedParameter = OpenAPI.Parameter | Thanks for clearing up the asymmetry here. 👍 |
swift-openapi-generator | github_2023 | others | 74 | apple | simonjbeaumont | @@ -164,3 +164,8 @@ extension FileTranslator {
)
}
}
+
+/// An unresolved OpenAPI response header.
+///
+/// Can be either a reference or an inline response header.
+typealias UnresolvedHeader = Either<JSONReference<OpenAPI.Header>, OpenAPI.Header> | Nit: The OpenAPI spec has the headers at a scope not specific to responses, e.g. when used in `#components/headers`.
```suggestion
/// An unresolved OpenAPI header.
///
/// Can be either a reference or an inline header.
typealias UnresolvedHeader = Either<JSONReference<OpenAPI.Header>, OpenAPI.Header>
``` |
swift-openapi-generator | github_2023 | others | 67 | apple | czechboy0 | @@ -133,31 +133,26 @@ extension ResponseKind {
extension Comment {
- /// Returns a documentation comment for an OpenAPI operation.
+ /// Returns a reference documentation string to attach to the generated function for an operation.
///
- /// For example: "Operation `getPet` performs `GET` on `/pets/{... | I'd prefer if we provided the necessary values explicitly, i.e. by adding `summary` and `description` as optional String parameters, instead of requiring a whole `OperationDescription`. That'll preserve its ability to be easily unit tested, whereas providing a whole `OperationDescription` would require bringing up a bu... |
swift-openapi-generator | github_2023 | others | 56 | apple | czechboy0 | @@ -0,0 +1,48 @@
+#!/usr/bin/env bash
+##===----------------------------------------------------------------------===##
+##
+## This source file is part of the SwiftOpenAPIGenerator open source project
+##
+## Copyright (c) 2023 Apple Inc. and the SwiftOpenAPIGenerator project authors
+## Licensed under Apache License ... | ```suggestion
PACKAGE_NAME=$(swift package --package-path "${PACKAGE_PATH}" describe --type json | $JQ_BIN -r .name)
``` |
swift-openapi-generator | github_2023 | others | 49 | apple | simonjbeaumont | @@ -0,0 +1,44 @@
+# Proposals
+
+Collaborate on API changes to Swift OpenAPI Generator by writing a proposal.
+
+## Overview
+
+For non-trivial changes that affect the public API, the Swift OpenAPI Generator project adopts a ligthweight version of the [Swift Evolution](https://github.com/apple/swift-evolution/blob/main... | Nit: re-implementing -> reimplementing
```suggestion
Writing a proposal first helps discuss multiple possible solutions early, apply useful feedback from other contributors, and avoid reimplementing the same feature multiple times.
``` |
swift-openapi-generator | github_2023 | others | 49 | apple | simonjbeaumont | @@ -0,0 +1,44 @@
+# Proposals
+
+Collaborate on API changes to Swift OpenAPI Generator by writing a proposal.
+
+## Overview
+
+For non-trivial changes that affect the public API, the Swift OpenAPI Generator project adopts a ligthweight version of the [Swift Evolution](https://github.com/apple/swift-evolution/blob/main... | Nit: extra space.
```suggestion
> Note: The goal of this process is to help solicit feedback from the whole community around the project, and we will continue to refine the proposal process itself. Use your best judgement, and don't hesitate to propose changes to the proposal structure itself!
``` |
swift-openapi-generator | github_2023 | others | 50 | apple | simonjbeaumont | @@ -0,0 +1,234 @@
+# Converting between data and Swift types
+
+Learn about the type responsible for convertering between raw data and Swift types.
+
+## Overview
+
+The [`Converter`](https://github.com/apple/swift-openapi-runtime/blob/main/Sources/OpenAPIRuntime/Conversion/Converter.swift) type is a structure defined ... | > "...emit a descriptive error..."
Don't we usually emit a diagnostic and try to continue? |
swift-openapi-generator | github_2023 | others | 50 | apple | simonjbeaumont | @@ -0,0 +1,234 @@
+# Converting between data and Swift types
+
+Learn about the type responsible for convertering between raw data and Swift types.
+
+## Overview
+
+The [`Converter`](https://github.com/apple/swift-openapi-runtime/blob/main/Sources/OpenAPIRuntime/Conversion/Converter.swift) type is a structure defined ... | ```suggestion
In `1.`, notice that the method name contains which schema location, content type family, and optionality; while in `2.` it contains the Swift type.
``` |
swift-openapi-generator | github_2023 | others | 50 | apple | simonjbeaumont | @@ -0,0 +1,234 @@
+# Converting between data and Swift types
+
+Learn about the type responsible for convertering between raw data and Swift types.
+
+## Overview
+
+The [`Converter`](https://github.com/apple/swift-openapi-runtime/blob/main/Sources/OpenAPIRuntime/Conversion/Converter.swift) type is a structure defined ... | While we might want to have the combinatorial explosion of methods internally, could they all be dispatched from one to help reduce the complexity in the generator.
I haven't fully thought this through, but something like:
```swift
func getParameter<T>(
name: String,
location: ParameterLocation,
... |
swift-openapi-generator | github_2023 | others | 50 | apple | simonjbeaumont | @@ -0,0 +1,234 @@
+# Converting between data and Swift types
+
+Learn about the type responsible for convertering between raw data and Swift types.
+
+## Overview
+
+The [`Converter`](https://github.com/apple/swift-openapi-runtime/blob/main/Sources/OpenAPIRuntime/Conversion/Converter.swift) type is a structure defined ... | Should I always read `codable` as JSON?
Are there other ways we can structure data that we want to support? If so, should we spell our API more explicitly to accommodate this, even if it's not going to be in the initial supported things?
|
swift-openapi-generator | github_2023 | others | 2 | apple | tomerd | @@ -61,7 +61,9 @@ let package = Package(
),
// Tests-only: Runtime library linked by generated code
- .package(url: "https://github.com/apple/swift-openapi-runtime", .upToNextMinor(from: "0.1.0")),
+ // FIXME: swift-openapi-runtime is private, so we can't access it anonymously yet
+ ... | seems fine for now, we can change later when made public? |
app-store-server-library-java | github_2023 | others | 97 | apple | izanger | @@ -1,5 +1,10 @@
# Changelog
+## Version 2.1.0
+- Incorporate changes for App Store Server API v1.11 and App Store Server Notifications v2.11 [https://github.com/apple/app-store-server-library-java/pull/94]
+- Add a proxy authenticator support [https://github.com/apple/app-store-server-library-java/pull/93] | Should this read `Add proxy authenticator support`?
|
app-store-server-library-java | github_2023 | java | 94 | apple | izanger | @@ -0,0 +1,45 @@
+// Copyright (c) 2024 Apple Inc. Licensed under MIT License.
+
+package com.apple.itunes.storekit.model;
+
+import com.fasterxml.jackson.annotation.JsonValue;
+
+/**
+ * The customer-provided reason for a refund request.
+ *
+ * @see <a href="https://developer.apple.com/documentation/appstoreservernot... | Nit: Why the letter b? |
app-store-server-library-java | github_2023 | java | 94 | apple | izanger | @@ -0,0 +1,44 @@
+// Copyright (c) 2024 Apple Inc. Licensed under MIT License.
+
+package com.apple.itunes.storekit.model;
+
+import com.fasterxml.jackson.annotation.JsonValue;
+
+/**
+ * A value that indicates your preferred outcome for the refund request.
+ *
+ * @see <a href="https://developer.apple.com/documentatio... | Same here |
app-store-server-library-java | github_2023 | others | 75 | apple | izanger | @@ -1,5 +1,9 @@
# Changelog
+## Version 1.1.0
+- Support App Store Server Notification v2.10 [#74] | Notification -> Notifications |
app-store-server-library-java | github_2023 | others | 75 | apple | izanger | @@ -1,5 +1,9 @@
# Changelog | Can we make this file an .md so GH renders it nicely? |
app-store-server-library-java | github_2023 | java | 60 | apple | izanger | @@ -9,40 +9,59 @@
*/
public class APIException extends Exception {
private final int httpStatusCode;
- private final Long apiError;
+ private final Long apiErrorCode;
+ private final String apiErrorMessage;
+
+ public APIException(int httpStatusCode, Exception cause) {
+ super("Failed to call... | Suggest renaming to `getRawApiErrorCode` or just `getApiErrorCode` |
app-store-server-library-java | github_2023 | java | 60 | apple | izanger | @@ -9,40 +9,59 @@
*/
public class APIException extends Exception {
private final int httpStatusCode;
- private final Long apiError;
+ private final Long apiErrorCode;
+ private final String apiErrorMessage;
+
+ public APIException(int httpStatusCode, Exception cause) {
+ super("Failed to call... | apiError -> apiErrorCode |
app-store-server-library-java | github_2023 | java | 60 | apple | izanger | @@ -10,60 +10,390 @@
* See the specific documentation for each endpoint to learn more about what codes are possible from each endpoint.
*/
public enum APIError {
+ /**
+ * An error that indicates an invalid request.
+ *
+ * @see <a href="https://developer.apple.com/documentation/appstoreserverapi/ge... | Suggest a rename to `INVALID_REQUEST_IDENTIFIER` |
app-store-server-library-java | github_2023 | others | 41 | apple | alexanderjordanbaker | @@ -0,0 +1,5 @@
+-----BEGIN PRIVATE KEY----- | How was this private key generated? |
app-store-server-library-java | github_2023 | others | 12 | apple | izanger | @@ -32,9 +32,10 @@ jobs:
run: >
sudo -E env "PATH=$PATH" bash -c "ulimit -l 65536 && ulimit -a &&
./gradlew properties --no-daemon --console=plain -q | grep -E '^version: [\.0-9]+\-SNAPSHOT$' &&
- ./gradlew --no-daemon --parallel clean check &&
+ (./gradlew --no-daemon ... | Is this trailing `"` still in the right place given the parentheses? |
pfl-research | github_2023 | python | 110 | apple | grananqvist | @@ -259,24 +259,24 @@ def evaluate(self,
postprocess_fns = []
allows_distributed_evaluation = True
# TODO: Use Dataset.iter interface.
- for start_index in range(0, len(dataset), batch_size):
+ for batch_idx, batch in enumerate(dataset.iter(batch_size)): | you don't use this batch variable, see how https://github.com/apple/pfl-research/pull/110/files#diff-f1f2212b462bbc2552740cdfff9215807fda11940ce307afa7cab9776fb3ee50R242 is done |
pfl-research | github_2023 | python | 110 | apple | grananqvist | @@ -259,24 +259,24 @@ def evaluate(self,
postprocess_fns = []
allows_distributed_evaluation = True
# TODO: Use Dataset.iter interface. | now you can remove this todo :) |
pfl-research | github_2023 | python | 105 | apple | grananqvist | @@ -0,0 +1,128 @@
+# Copyright © 2023-2024 Apple Inc.
+'''
+Joint mechanism for combining multiple mechanisms into one.
+'''
+
+from typing import Dict, List, Optional, Set, Tuple
+
+from pfl.metrics import Metrics, StringMetricName
+from pfl.stats import MappedVectorStatistics, TrainingStatistics
+
+from .privacy_mech... | can you do `f'{prefix} | {n}'` , like how metrics are usually formatted |
pfl-research | github_2023 | python | 105 | apple | grananqvist | @@ -0,0 +1,128 @@
+# Copyright © 2023-2024 Apple Inc.
+'''
+Joint mechanism for combining multiple mechanisms into one.
+'''
+
+from typing import Dict, List, Optional, Set, Tuple
+
+from pfl.metrics import Metrics, StringMetricName
+from pfl.stats import MappedVectorStatistics, TrainingStatistics
+
+from .privacy_mech... | `statistics.weight` is lost here. can you make sure it is preserved in the return object and this is discovered in the tests? |
pfl-research | github_2023 | python | 105 | apple | grananqvist | @@ -484,3 +485,228 @@ def test_norm_clipping_only(self, order, clipping_bound, expected_arrays,
is_local_privacy=True)
assert get_overall_value(
metrics[name]) == pytest.approx(expected_clip_fraction)
+
+ @pytest.mark.parametrize('ops_module', framework_fixture... | Since the mechanisms themselves are tested in other unittests, you can simplify this a lot by just using MagicMock as mechanisms input to JointMechanism.
and the test will be much faster, as i recall these statistical tests are not super fast. |
pfl-research | github_2023 | python | 105 | apple | grananqvist | @@ -0,0 +1,128 @@
+# Copyright © 2023-2024 Apple Inc.
+'''
+Joint mechanism for combining multiple mechanisms into one.
+'''
+
+from typing import Dict, List, Optional, Set, Tuple
+
+from pfl.metrics import Metrics, StringMetricName
+from pfl.stats import MappedVectorStatistics, TrainingStatistics
+
+from .privacy_mech... | is it possible to add a feature to also allow specify keys by sub path. e.g. if i have an LLM (which produce many keys) and then some other stats `algo/value1`, `algo/value2`, ... etc i want to put through a mechanism, it would be great if you can achieve this by:
```
mechanisms_and_keys = {
'algo_mechanism': (m... |
pfl-research | github_2023 | python | 105 | apple | grananqvist | @@ -0,0 +1,128 @@
+# Copyright © 2023-2024 Apple Inc.
+'''
+Joint mechanism for combining multiple mechanisms into one.
+'''
+
+from typing import Dict, List, Optional, Set, Tuple
+
+from pfl.metrics import Metrics, StringMetricName
+from pfl.stats import MappedVectorStatistics, TrainingStatistics
+
+from .privacy_mech... | make this private `_check_if_partition` |
pfl-research | github_2023 | python | 100 | apple | ac554 | @@ -167,7 +167,12 @@ def __init__(self):
hvd.local_rank(), hvd.local_size(), hvd.rank(), hvd.size())
self._post_init_check(hvd)
- if torch.cuda.is_available():
+ if torch.cuda.is_available( | Do you need an `else` clause if `"CUDA_VISIBLE_DEVICES" not in os.environ`? |
pfl-research | github_2023 | python | 100 | apple | ac554 | @@ -296,12 +301,42 @@ def __init__(self, seed=None):
def __enter__(self):
if self._seed is not None:
- self._saved_state = torch.random.get_rng_state()
+ self._saved_state = {"cpu": torch.random.get_rng_state()}
+ try:
+ self._saved_state["cuda"] = torch.c... | Where is this class used? |
pfl-research | github_2023 | python | 100 | apple | ac554 | @@ -296,12 +301,42 @@ def __init__(self, seed=None):
def __enter__(self):
if self._seed is not None:
- self._saved_state = torch.random.get_rng_state()
+ self._saved_state = {"cpu": torch.random.get_rng_state()}
+ try: | Should we not check if cuda or mps are available rather than having two try-except blocks, with at least one of these blocks generating a "Failed to get ..." message?
E.g. using `if torch.cuda.is_available():` and `if torch.backends.mps.is_available():` |
pfl-research | github_2023 | python | 102 | apple | grananqvist | @@ -160,22 +160,6 @@ def pytorch_model(self) -> torch.nn.Module:
def variable_map(self) -> Dict[str, torch.Tensor]:
return self._variable_map
- @property
- def central_optimizer_variable_map( | This is removing a public interface, it should remain. If you still have this you shouldn't need to make changes in tests no? |
pfl-research | github_2023 | python | 82 | apple | congzheng-song | @@ -0,0 +1,151 @@
+# Copyright © 2024 Apple Inc.
+import math
+import mlx.core as mx
+import mlx.nn as nn
+from mlx.utils import tree_flatten
+from pfl.metrics import Weighted
+
+from model.numpy.layer import positional_encoding
+from model.numpy.metrics import Perplexity
+
+
+class PositionalEncoding(nn.Module):
+ ... | I am not sure if we need this comment |
pfl-research | github_2023 | python | 80 | apple | congzheng-song | @@ -0,0 +1,158 @@
+# Copyright © 2023-2024 Apple Inc.
+import argparse
+import logging
+import os
+from functools import partial
+from uuid import uuid4
+
+import mlx
+import mlx.core as mx
+import mlx.nn as nn
+import numpy as np
+import torch # type: ignore | `import torch` not needed? |
pfl-research | github_2023 | python | 80 | apple | congzheng-song | @@ -0,0 +1,316 @@
+# Copyright © 2023-2024 Apple Inc.
+import logging
+import os
+import uuid
+from typing import Callable, Dict, Optional, Tuple
+
+import mlx
+import mlx.core as mx
+import mlx.nn as nn
+import mlx.optimizers
+
+from pfl.data.dataset import AbstractDatasetType
+from pfl.exception import CheckpointNotF... | The example below is still for `torch`, needs to be updated for `mlx` |
pfl-research | github_2023 | python | 80 | apple | congzheng-song | @@ -0,0 +1,316 @@
+# Copyright © 2023-2024 Apple Inc.
+import logging
+import os
+import uuid
+from typing import Callable, Dict, Optional, Tuple
+
+import mlx
+import mlx.core as mx
+import mlx.nn as nn
+import mlx.optimizers
+
+from pfl.data.dataset import AbstractDatasetType
+from pfl.exception import CheckpointNotF... | remove? |
pfl-research | github_2023 | python | 80 | apple | congzheng-song | @@ -0,0 +1,93 @@
+# Copyright © 2023-2024 Apple Inc.
+
+import types
+from typing import List, Tuple
+
+import mlx.core as mx
+import mlx.nn as nn
+import numpy as np
+from mlx.utils import tree_flatten
+
+from pfl.metrics import Weighted
+
+
+def maxpool2d(x, pool_size=2, stride=2):
+ batch, height, width, channels... | This is fixed in https://github.com/ml-explore/mlx/pull/1237, so we will need to monitor which mlx version has this change, and update here. |
pfl-research | github_2023 | others | 74 | apple | ac554 | @@ -15,6 +15,29 @@
*
+## v0.2.0
+
+### Breaking change!
+
+* `EMMGMMHyperParams` is renamed to `EMGMMHyperParams` (#55)
+
+### New features
+
+* Return local metadata from model training to algorithm (#71).
+
+### Tasks completed
+
+* Update FLAIR preprocessing script to download new dataset from HuggingFace, ava... | Leave out "new", from "download new dataset", since the dataset is not new. |
pfl-research | github_2023 | python | 73 | apple | ac554 | @@ -132,6 +132,20 @@ def add_dataset_arguments(
default=100,
help='Maximum number of images per user')
+ parser.add_argument(
+ '--scheduling_base_weight_multiplier',
+ type=float,
+ default=1.0,
+ help=('Figu... | How does one set the "base weight"? I don't see any arg allowing one to set it. I think this should be parameterised. |
pfl-research | github_2023 | python | 73 | apple | ac554 | @@ -11,12 +12,15 @@
from .common import get_label_mapping, get_multi_hot_targets, get_user_num_images
+logger = logging.getLogger(name=__name__)
+
def make_federated_dataset(
hdf5_path: str,
partition: str,
use_fine_grained_labels: bool,
max_num_user_images: int,
+ sch... | This function now also controls the scheduling of users through a greedy algorithm. This is not alluded to in this docstring. |
pfl-research | github_2023 | python | 73 | apple | ac554 | @@ -37,8 +41,21 @@ def make_federated_dataset(
Federated dataset from the HDF5 data file.
"""
num_classes = len(get_label_mapping(hdf5_path, use_fine_grained_labels))
- user_num_images = get_user_num_images(hdf5_path, partition)
- user_ids = sorted(user_num_images.keys())
+ user_id_to_weight... | This feels like new functionality which should be abstracted out of this function `make_federated_dataset`. |
pfl-research | github_2023 | python | 73 | apple | ac554 | @@ -266,7 +266,7 @@ def test_3_workers(self, mock_get_ops, federated_dataset_mixture,
@pytest.fixture
def user_id_to_weight(request):
if hasattr(request, 'param') and request.param:
- return {i: i for i in range(100)}
+ return {i: i + 1 for i in range(100)} | I presume the "1" is for base weight? Perhaps a comment, or creating a variable name, `base_weight=1`, would help with legibility. |
pfl-research | github_2023 | python | 73 | apple | congzheng-song | @@ -11,12 +12,15 @@
from .common import get_label_mapping, get_multi_hot_targets, get_user_num_images
+logger = logging.getLogger(name=__name__)
+
def make_federated_dataset(
hdf5_path: str,
partition: str,
use_fine_grained_labels: bool,
max_num_user_images: int,
+ sch... | It is a float right? from the argparse above |
pfl-research | github_2023 | python | 71 | apple | ac554 | @@ -72,20 +72,25 @@ def new_local_optimizer(*args, **kwargs):
return mock_local_optimizer
pytorch_model_setup.model.new_local_optimizer = new_local_optimizer
- bridges.sgd_bridge().do_sgd(
- pytorch_model_setup.model, user_dataset,
+ # This is same as bridges.sgd_bridge(... | I was confused about the "2" here. It's the `len(user_dataset) / local_batch size`, correct? I think writing it like this would make it much more legible in the tests. |
pfl-research | github_2023 | python | 70 | apple | mdmauthors | @@ -347,6 +338,15 @@ def __call__(self, parser, namespace, values, option_string=None):
'sampled to participate again. This parameter is used in '
'`BandedMatrixFactorizationMechanism`.')
+ argument_parser.add_argument(
+ '--noise_cohort_size',
+ type=int,
+ default=1000,
+ ... | Change "in" to "when":
"The cohort size to use when calculating noise for DP" |
pfl-research | github_2023 | python | 70 | apple | mdmauthors | @@ -347,6 +338,15 @@ def __call__(self, parser, namespace, values, option_string=None):
'sampled to participate again. This parameter is used in '
'`BandedMatrixFactorizationMechanism`.')
+ argument_parser.add_argument(
+ '--noise_cohort_size',
+ type=int,
+ default=1000,
+ ... | Please add description of what happens to standard deviation of noise when `noise_cohort_size` > `cohort_size`. |
pfl-research | github_2023 | python | 34 | apple | monachitnis | @@ -0,0 +1,116 @@
+# Copyright © 2023-2024 Apple Inc.
+from typing import Optional
+
+from lm.argument_parsing import add_lm_arguments
+from peft import LoraConfig, PeftConfig, TaskType | so this `peft` package is compatible with horovod, and makes single GPU, multi-process training work? |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.