-
Notifications
You must be signed in to change notification settings - Fork 84
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
H-345: Fix hash-graph-client
class names
#2872
Conversation
Moved most things into To be able to accommodate these changes I switched from the (turns out that There are still some left that have numbers in their name, I'll try to remove them in one of the other commits. |
The issue in question about |
hash-graph-client
class nameshash-graph-client
class names
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.
The names are much much better!
|
||
|
||
class VersionedUrl(RootModel): | ||
class DataType(BaseModel): |
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 wonder if we can use downstream either the custom models I've written (removing this) or use this as base class for the custom model. I think they match?
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.
That should be possible indeed, only has the side-effect that we do not have a common Schema
base (which is helpful in some circumstances), but using --reuse-model
we can probably coerce datamodel-code-generator
into creating one^^
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.
The types should now have parity with the ones in the hash-graph-types; I'd personally prefer if we keep the "chain," meaning graph-client
as the base (as it is the most low level). The only problem I see is that (unlike Rust) Python offers no real way for composing and extending existing classes, except for subclassing.
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.
As this is already a BaseModel
this should be fine I guess?
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2872 +/- ##
==========================================
- Coverage 51.76% 51.72% -0.05%
==========================================
Files 337 337
Lines 28901 28916 +15
Branches 431 431
==========================================
- Hits 14960 14956 -4
- Misses 13939 13958 +19
Partials 2 2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
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 needed to move this out, because openapi-generator
doesn't understand nested relative paths properly.
If I am pointing at ./shared.json
in models/property_type.json
it still searches for shared.json
in the openapi
directory. Like datamodel-code-generator
I switched to @redocly/cli
to bundle everything beforehand, but that comes with it's own challenges, for status.json
it doesn't remove the definitions
, and instead of ignoring it, openapi-generator
just errors out, moving this to a separate filed solved the problem.
Although i don't know why the problem wasn't there in the first place... 🤔
apps/hash-graph/lib/graph/src/api/rest/json_schemas/status.json
Outdated
Show resolved
Hide resolved
pub trait TemporalAxis { | ||
/// The name of the temporal axis. | ||
fn noun() -> &'static str; | ||
} |
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.
Honestly: I really don't like this. This feels like adding reflection to a type where it does not belong to. I see why you did that. If we don't find a better solution or want to implement this manually we should move this trait to utoipa_typedefs.rs
as this absolutely does not belong here.
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 first had this in utoipa_typedefs.rs
(under the name TemporalSchema
or TemporalAxisInfo
), but the schema for the axis isn't located utoipa_typedef
, and I didn't want to pub
out of api/rest
.
(Personally also don't really like this, but it was the only way I found works in a Rust-like way without too much overhead.)
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.
Is it only used in temporal_asxes.rs
? Then let's define it there and make it private to that module.
@@ -7,7 +7,7 @@ | |||
"main": "index.ts", | |||
"scripts": { | |||
"build": "echo 'no build needed, this is here to orchestrate turborepo'", | |||
"codegen": "openapi-generator-cli generate" | |||
"codegen": "redocly bundle --format=json -o openapi.bundle.json ../../../../apps/hash-graph/openapi/openapi.json && openapi-generator-cli generate && rm openapi.bundle.json" |
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.
How does this play together with the caching as this is creating a temporary file?
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.
Nothing changes; it's simply a buffer, as I had some problems directly piping in stdout. The bundle output is the same if the schema is the same, so no worries.
pub trait TemporalAxis { | ||
/// The name of the temporal axis. | ||
fn noun() -> &'static str; | ||
} |
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.
Is it only used in temporal_asxes.rs
? Then let's define it there and make it private to that module.
Co-authored-by: Tim Diekmann <[email protected]>
🌟 What is the purpose of this PR?
This fixes the class names generated by
hash-graph-client
done through a combination of factors.🔗 Related links
hash-graph-sdk
Python functionality #2868 (comment)Pre-Merge Checklist 🚀
🚢 Has this modified a publishable library?
This PR:
📜 Does this require a change to the docs?
The changes in this PR:
🕸️ Does this require a change to the Turbo Graph?
The changes in this PR:
📹 Demo