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

[DO NOT MERGE] Code review #53

Draft
wants to merge 25 commits into
base: pre-apis
Choose a base branch
from
Draft

[DO NOT MERGE] Code review #53

wants to merge 25 commits into from

Conversation

jairad26
Copy link
Member

@jairad26 jairad26 commented Jan 3, 2025

No description provided.

jairad26 and others added 19 commits December 18, 2024 13:28
Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from
0.29.0 to 0.31.0.
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/golang/crypto/commit/b4f1988a35dee11ec3e05d6bf3e90b695fbd8909"><code>b4f1988</code></a>
ssh: make the public key cache a 1-entry FIFO cache</li>
<li><a
href="https://github.com/golang/crypto/commit/7042ebcbe097f305ba3a93f9a22b4befa4b83d29"><code>7042ebc</code></a>
openpgp/clearsign: just use rand.Reader in tests</li>
<li><a
href="https://github.com/golang/crypto/commit/3e90321ac7bcee3d924ed63ed3ad97be2079cb56"><code>3e90321</code></a>
go.mod: update golang.org/x dependencies</li>
<li><a
href="https://github.com/golang/crypto/commit/8c4e668694ccbaa1be4785da7e7a40f2ef93152b"><code>8c4e668</code></a>
x509roots/fallback: update bundle</li>
<li>See full diff in <a
href="https://github.com/golang/crypto/compare/v0.29.0...v0.31.0">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=golang.org/x/crypto&package-manager=go_modules&previous-version=0.29.0&new-version=0.31.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)
You can disable automated security fix PRs for this repo from the
[Security Alerts
page](https://github.com/hypermodeinc/modusDB/network/alerts).

</details>

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
This PR adds the initial issue and PR templates, a changelog, code of
conduct, contributing guide, and security reporting instructions. We can
enhance these over time.
**Description**

Initialize Trunk for broader linting and security monitoring. Fix
addressable issues.

**Checklist**

- [x] Code compiles correctly and linting passes locally
**Description**

add readme to repo
<!-- markdownlint-disable first-line-heading -->

**Description**

Adds copyrights to all go files

**Checklist**

- [x] Code compiles correctly and linting passes locally
- [ ] For all _code_ changes, an entry added to the `CHANGELOG.md` file
describing and linking to
      this PR
- [x] Tests added for new functionality, or regression tests for bug
fixes added as applicable
- [ ] For public APIs, new features, etc., PR on [docs
repo](https://github.com/hypermodeinc/docs)
      staged and linked here

Thank you for your contribution to modusDB!
**Description**

Move GitHub Actions workflows to Warp runners for faster tests through
larger machine access.

**Checklist**

- [X] Code compiles correctly and linting passes locally
<!-- markdownlint-disable first-line-heading -->

**Description**

This PR adds support for reverse edges via the readFrom json tag

**Checklist**

- [x] Code compiles correctly and linting passes locally
- [x] For all _code_ changes, an entry added to the `CHANGELOG.md` file
describing and linking to
      this PR
- [x] Tests added for new functionality, or regression tests for bug
fixes added as applicable
- [ ] For public APIs, new features, etc., PR on [docs
repo](https://github.com/hypermodeinc/docs)
      staged and linked here
**Description**

refactoring packages for clearer code, remove duplications, etc

**Checklist**

- [x] Code compiles correctly and linting passes locally
- [x] For all _code_ changes, an entry added to the `CHANGELOG.md` file
describing and linking to
      this PR
- [ ] Tests added for new functionality, or regression tests for bug
fixes added as applicable
- [ ] For public APIs, new features, etc., PR on [docs
repo](https://github.com/hypermodeinc/docs)
      staged and linked here
**Description**

more refactoring to simplify code in main modusdb package
**Checklist**

- [x] Code compiles correctly and linting passes locally
Copy link
Member

@mangalaman93 mangalaman93 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also do not understand the package structure having two levels of hierarchy with just one file in each package. This does not feel useful to me. packages are for dividing code for logically structuring it. I don't see that here.

This is a 10000 feet view of the PR. I will do another pass once some of these comments are addressed. This is a very long PR to review.

"github.com/hypermodeinc/modusdb/api/utils"
)

func HandleReverseEdge(jsonName string, value reflect.Type, nsId uint64, sch *schema.ParsedSchema,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should move these to internal package if we want to have this package structure.

api/mutations/mutations.go Outdated Show resolved Hide resolved
return fmt.Sprintf(ObjQuery, qf(), extraFields)
}

func FormatObjsQuery(typeName string, qf QueryFunc, paginationAndSorting string, extraFields string) string {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the benefit of passing a function qf instead of passing the return value here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

formatObjsQuery doesn't need queryfunc, its there to maintain code readability bc formatObjQuery does need it. it makes more sense if they both follow using qf

api/utils/reflect.go Outdated Show resolved Hide resolved
api/utils/utils.go Outdated Show resolved Hide resolved
return gid, nil
}

func applyDqlMutations(ctx context.Context, db *DB, dms []*dql.Mutation) error {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the functions that do mutations and query or alter or any other Dgraph operation, that should use moduDB APIs or equivalent so that we can make changes to it easily.

**Description**

On query of a type with a reverse edge, it modifies the type to remove
all other predicates. The expected logic should only alter the schema if
the type and predicate for the reverse edge does not exist.
**Checklist**

- [x] Code compiles correctly and linting passes locally
- [x] For all _code_ changes, an entry added to the `CHANGELOG.md` file
describing and linking to
      this PR
- [x] Tests added for new functionality, or regression tests for bug
fixes added as applicable
- [ ] For public APIs, new features, etc., PR on [docs
repo](https://github.com/hypermodeinc/docs)
      staged and linked here
Comment on lines +9 to +28
**Describe the bug** A clear and concise description of what the bug is.

**To Reproduce** Steps to reproduce the behavior:

1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior** A clear and concise description of what you expected to happen.

**Screenshots** If applicable, add screenshots to help explain your problem.

**Environment**

- OS: [e.g. macOS, Windows, Ubuntu]
- Language [e.g. Go]
- Version [e.g. v0.xx]

**Additional context** Add any other context about the problem here.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trunk merged the title and body of these paragraphs, because they were just bold text rather than headings. Use ## headings instead.

Comment on lines +9 to +17
**Is your feature request related to a problem? Please describe.** A clear and concise description
of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like** A clear and concise description of what you want to happen.

**Describe alternatives you've considered** A clear and concise description of any alternative
solutions or features you've considered.

**Additional context** Add any other context or screenshots about the feature request here.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trunk merged the title and body of these paragraphs, because they were just bold text rather than headings. Use ## headings instead.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding a section about Trunk. Feel free to copy from the one I did in Modus.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like it was copied from the Modus repo, but I've recently changed the text there. Please consider updating to match. (At minimum, update the headings to use ## markdown.)

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, setup-go when using go-version-file does not recognize the toolchain directive in the file. See: actions/setup-go#457

That means it will install the version from the go directive (1.22.7), not 1.23.x that you might expect.

So instead, configure manually and keep it updated.

Suggested change
go-version-file: go.mod
go-version: 1.23.4

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is in trunk's configs dir, you'll be fighting against VS Code expecting it in the root. Trunk will have this config, and VS Code will have the default config.

You can fix that by adding the following to .vscode/settings.json

  "markdownlint.config": {
    "extends": ".trunk/configs/.markdownlint.json"
  },

CHANGELOG.md Outdated
- feat: add readfrom json tag to support reverse edges
[#49](https://github.com/hypermodeinc/modusDB/pull/49)

- chore: Refactoring package management #51 [#51](https://github.com/hypermodeinc/modusDB/pull/51)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- chore: Refactoring package management #51 [#51](https://github.com/hypermodeinc/modusDB/pull/51)
- chore: Refactoring package management [#51](https://github.com/hypermodeinc/modusDB/pull/51)


If in doubt or contemplating a larger change, join the
[Hypermode Discord](https://discord.hypermode.com) and start a discussion in the
[#modus](https://discord.com/channels/1267579648657850441/1292948253796466730) channel.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
[#modus](https://discord.com/channels/1267579648657850441/1292948253796466730) channel.
[#modusdb](https://discord.com/channels/1267579648657850441/1324490523725135872) channel.

}

func main() {
db, err := New(NewDefaultConfig("/tmp/modusdb"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
db, err := New(NewDefaultConfig("/tmp/modusdb"))
cfg := modusdb.NewDefaultConfig("/tmp/modusdb")
db, err := modusdb.New(cfg)

}
fmt.Println(user)

_, queriedUser, err := modusdb.Get[User](db, gid)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's unclear what the _ return value is. If it's the gid, why does the API accept a gid and also return one? Could they differ somehow?

"github.com/hypermodeinc/modusdb/api/apiutils"
"github.com/hypermodeinc/modusdb/api/structreflect"
)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add usage comments for at least these primary public functions. Otherwise, it's difficult to tell what the parameters and return values are supposed to be. Thanks.

Copy link
Member

@mattjohnsonpint mattjohnsonpint Jan 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These tests take too long. Please separate this and other long-running integration tests using build tags. Thanks.

if len(ns) > 1 {
return nil, nil, fmt.Errorf("only one namespace is allowed")
}
ctx, n, err := getDefaultNamespace(db, ns...)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here and in the rest of the API methods, we are creating the ctx context object ourselves inside the getDefaultNamespace function. Instead, we should be allowing the user to pass context in as a parameter (usually the first parameter).

For example, say the user wants the query to timeout if it takes to long to run. The normal way would be to use context.WithTimeout and pass that context in to the query function. But we've not given them any way to do that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... Also, it's unclear why there is Query as a global function that doesn't take a context but takes a db and a namespace, and db.Query which does take a context, but not a namespace.

IMHO, There should just be one way to query, not two.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants