Type error: Cannot find module 'epubjs' or its corresponding type declarations.

info  - Checking validity of types...
21:48:24.825 | Failed to compile.
21:48:24.825 |
21:48:24.825 | ./components/previews/EPUBPreview.tsx:3:32
21:48:24.825 | Type error: Cannot find module 'epubjs' or its corresponding type declarations.
21:48:24.825 |
21:48:24.825 | 1 | import { FC, useEffect, useRef, useState } from 'react'
21:48:24.825 | 2 | import { ReactReader } from 'react-reader'
21:48:24.826 | > 3 | import type { Rendition } from 'epubjs'
21:48:24.826 | |                                ^
21:48:24.826 | 4 |
21:48:24.826 | 5 | import Loading from '../Loading'
21:48:24.826 | 6 | import DownloadButtonGroup from '../DownloadBtnGtoup'
21:48:24.842 | ELIFECYCLE  Command failed with exit code 1.
21:48:24.855 | Error: Command "pnpm build" exited with 1

epubjs is a dependency of react-reader, and it is also included in the lock file:
https://github.com/spencerwooo/onedrive-vercel-index/blob/152380bd057d256bcd6cf3ececefcf5826fecaf9/pnpm-lock.yaml#L1326
And locally I can not reproduce the error.
Maybe you could try pnpm install first.
Checking if you are using the latest version may be also helpful.

the module "@fortawesome/fontawesome-common-types" cannot be found

This should be resolved by #642

some good, it's working fine now, thank you again for your patience
╰─$ pnpm build
><EMAIL_ADDRESS>build /home/kali/temp/onedrive-vercel-index
> next build

info  - Checking validity of types
info  - Creating an optimized production build ...                                                  info  - Creating an info  iinfo  - Creating an optimized production build
info  - Compiled successfully
info  - Collecting page data
info  - Generating static pages (6/6)
info  - Finalizing page optimization

Page                                              Size     First Load JS
┌ ○ / (628 ms)                                    487 B           590 kB
├   /_app                                         0 B             296 kB
├ ○ /[...path] (647 ms)                           531 B           590 kB
├ ○ /404                                          196 B           297 kB
├ λ /api                                          0 B             296 kB
├ λ /api/proxy                                    0 B             296 kB
├ ○ /onedrive-vercel-index-oauth/step-1 (440 ms)  3.5 kB          322 kB
├ ○ /onedrive-vercel-index-oauth/step-2 (490 ms)  1.97 kB         347 kB
└ λ /onedrive-vercel-index-oauth/step-3           2.41 kB         348 kB
+ First Load JS shared by all                     296 kB
  ├ chunks/framework-0e98bcaf2420af3e.js          42.1 kB
  ├ chunks/main-973fbe287b882966.js               28.7 kB
  ├ chunks/pages/_app-3961b070c1682171.js         224 kB
  ├ chunks/webpack-048d53d5b082155e.js            1.8 kB
  └ css/33778090a30883bc.css                      9.16 kB


Clean console.log from code

Code where it left

:+1:

this issue gets my vote, it's ridiculous to see console.log in minified build

Gone, we we have a grunt script that removes them from any distributed release


Links to Cognitive Services sources and samples broken in README.md

All links to Cognitive Services sources and samples in README.md are not valid.

@lenala I don't see cognitive Services docs in main README.md, can you mention more details for this issue or if we can close it please?

There is no info about cognitive services in root Readme and there is not readme file in sdk/cognitiveservices path.
Closing this


How to contribute

Hi, ppls, today we officially introduced TravisCI into MatchZoo to get rid of technical debt.
If anyone happened to figure out any bug or enhancement, please follow this pipeline:

Fork the latest version of MatchZoo into your repo. (exclude core developers)
Create an issue under faneshion/Matchzoo, write the description of the bug/enhancement.
Clone your forked MatchZoo into your machine, edit code.
Run make init and make test  using terminal/command line, ensure dependency check & unit tests passed on your computer.
Push to your forked repo, send the pull request, in PR, you need to create a link to the issue you created using #[issue_id], and describe what has been changed.
Wait CI passed.
We'll review the code and merge PR

Thanks!

For core developers:

Create a sub-branch under dev, naming conventions:

For new features or enhancements, use feature/[branch-name].
For bugs, use hotfix/[branch-name]

Create an issue under faneshion/Matchzoo, write the description of the bug/enhancement.
git pull to get the latest code, git checkout feature/[branch-name] to switch to you newly created branch.
Edit code.
Run make init and make test to ensure all the dependencies & unit tests has been passed.
Create a new PR, assign yourself as assignees, assign 1 or 2 reviewers to review your code.
Create a  link between your PR & Issue using #[issue-id].
Wait  CI passed.
Wait all reviewers agreed this piece of code can be merged into the code base.
IMPORTANT: USE SQUASH AND MERGE INSTEAD OF MERGE!
Close issue you created.
Remove sub-branch you created for this issue (i.e. feature/branch-name or hotfix/branch-name) locally and remotely.

More:

we expect your code to be Pythonic, which means it should at least satisfy PEP8 standard (Don't worry we'll review your code).
We expect your code change has corresponded unit-test. Currently, we're using Unittest, later we might shift to pytest.

Is it possible to create my own version and be updated automatically with different changes? If so, how can I get it?

@thiziri clone the repo, do your magic, and rebase onto the master once the master here updates.

Yes, I'm still working the previous version, a lot of updates are made, now I've forked my repo. If I understand, now, all that I have to do is:
1- do my magic (as you said)
2- commit to my repo
3- merge with master
Is that correct?

@thiziri Haha now we're developing 2.0 version of MatchZoo! Most of the development will happen on branch 2.0 (serve as master).

Do you mean this one? There are not all the folders that are present in the master one. Do you mind give some clarifications, please ? how can I keep my repo up to date and contribute...? (my last question)

Okay, thank you. I'll read this to learn more, then back here if I have other questions.
Thanks

@thiziri no problem :)


Automate PyPI releases

I want to outsource some of the publishing machinery (especially to lower the risk of packaging some local garbage).
This flow has the following ideas:

it moves package issues into a separate workflow
on every push it still builds and verifies the package using my build-and-inspect-python-package action for continuous packaging monitoring.
on pushed tags, it pushes the package test PyPI which allows last-second checks
on GitHub Release, it finally pushes the package to the real PyPI (graciously stolen from @hugovk)

Unfortunately, I'm not sure how to test any of this, except maybe tagging an rc or something?

Hooray for more automation!

Unfortunately, I'm not sure how to test any of this, except maybe tagging an rc or something?

It can take a bit of trial and iteration to get working first time.
But we have the TestPyPI bit, you could temporarily test that out on this auto-publish branch first to increase confidence.
And an RC sounds good after that (or make a full release, it's been a while since July ;)

I would love to publish (this is the last step basically); but would love to verify somehow that it works first. 😅

Unfortunately, I'm not sure how to test any of this, except maybe tagging an rc or something?

In @aio-libs, the testing is often done by making a .a0 release or .dev0. These seem more appropriate than release candidates. They are also pre-releases from the PoV of PEP 440, pip and PyPI.
Although, I prefer a different school of thought personally which infolves a more tightly integrated workflow triggered by a workflow_dispatch event (essentially, it's an input from on GH), which being the initial trigger, allows to let the automation produce all the release-related pieces (Towncrier commit, tag, GH release with a linked discussion etc.)
With that, I aim to have job(s) for building dists at the first stage, followed by the testing that actually imports whatever's shipped in those dists rather than a Git checkout, and finally an environment-protected job for publishing the same artifacts that were tested rather than rebuilding them with possible differences.
Another approach I use is continuously publishing to PyPI on merges to the default branch. The versions produced by setuptools-scm help me with that.

One extra testing possibility is to use devpi — it got recently integrated into the pypi-publish action smoke test. But not sure what you'd test with that — certainly not whether the secrets are correct.

required-checks-pass Expected — Waiting for status to be reported Required

You may need to have a job with the same name in this workflow. This is one of the things that you don't have to deal with when you have a unified workflow. Though, if there are cases when both workflows are triggered for the PR, they can create confusion for automerge — if one reports success, GH will count that as a fulfilled branch protection condition even though the other workflow may still be running. This is because these things are dynamic and the GitHub platform does not know what will report the ~status~check with the same name. It's easier with GitHub Apps since you can now scope the expected check to specific bots but if there are several workflows reporting statuses via Checks API, they are all coming from the same GH App so there's no way to declare such expectations on the repo settings level.

it moves package issues into a separate workflow

As a follow up to the last comment, I'd like to point out that reusable workflows are a thing and you can now refer to the workflows in the same repo. So this may help you better structure the job definitions in multiple files while wiring them to the events/triggers in the main one.
Another solution would be integrating some sort of polling into the job that produces the final status for branch protection. I've seen an action facilitating this somewhere. But this does not seem elegant.

it moves package issues into a separate workflow

As a follow up to the last comment, I'd like to point out that reusable workflows are a thing and you can now refer to the workflows in the same repo. So this may help you better structure the job definitions in multiple files while wiring them to the events/triggers in the main one. Another solution would be integrating some sort of polling into the job that produces the final status for branch protection. I've seen an action facilitating this somewhere. But this does not seem elegant.

I'm sorry but I don't understand almost any of this. :D
I've decided to go a slightly less DRY, but more explicit and clear way of splitting it up and protecting the whole jobs. Does this make sense?
re: workflow_dispatch: my impression is, that using the released event, I'm getting basically the same thing?

I guess it's easiest to merge and play with the test env

I've decided to go a slightly less DRY, but more explicit and clear way of splitting it up and protecting the whole jobs. Does this make sense?

When you don't have an artifact upload job, you can't download the artifacts for inspection. I suppose it may work for you at the cost of building the dists twice. You can then inspect the dists by downloading them from (Test)PyPI.

re: workflow_dispatch: my impression is, that using the released event, I'm getting basically the same thing?

That depends on the PoV. It's definitely not 100% the same, but people do use both of these as triggers. The number of things and ways you can automate stuff varies for these two.
The released event happens when you make a GitHub Release. GitHub Release requires a Git tag. So by the time the workflow is triggered, you've created something in Git and published it to GitHub. The workflow may produce broken dists or fail, but the GitHub Release and the tag already exist, and some external automations may start advertising the fact that you've made a release while there's nothing yet on PyPI, and there won't be. You may end up being forced to remove the tag and tag a different commit with the same thing. Another implication of this is having a human-driven manual step for generating a changelog and committing that. This is where things may become fragile — the human factor may play a bad joke.
With the workflow_dispatch, you can define your own inputs and get a form in the UI where you can enter the desired version. You fill that out, click a button and a workflow is triggered. At this point, there's nothing mutated on GitHub or in the Git repo. The artifacts may get tested, changelog may be generated and this will be a part of the GHA workflow run up until the point when there's some verification that all the bits fit together. I like publishing to PyPI and only then pushing a commit+tag for that release — at a point when the automation knows the release was successful.
The TestPyPI job runs in parallel and is conditional on the build/test, but is pretty much automatic. So at some point in the workflow, there's something released to TestPyPI and the PyPI job is frozen (by the env approval requirement). This is when you can inspect what got published to TestPyPI (but not to GitHub, no commit, no tag, no release) and click approve on the main release job which could be followed by committing the final stuff back to GitHub.
So this is the difference for me.

Right, I already have plenty local automation so for me this is a meaningful step anyway.
What I'll be doing is leaving out the upload locally and have a last chance to check the readme on Test PyPI etc before starting the release and upload to PyPI proper. I agree tho that it probably gets hairy if I notice a problem, since I can't just delete the version from test PyPI (which is a bummer).
I might go the constantly-uploading route once I'm on hatch-vcs, but it seems like an enormous waste of resources to store every main commit. :|

Well, it didn't work because I didn't know that there's a separate hostname for uploads. sigh.
f04dce2

I agree tho that it probably gets hairy if I notice a problem, since I can't just delete the version from test PyPI (which is a bummer).

FWIW there's an effort to implement draft uploads in PyPI that seems to be slowly moving towards resolution — it'll allow deleting/reuploading drafts w/o having to burn through versions.
Another ongoing effort is the OIDC integration that allows throwing away the tokens saved as repo secrets and would let us make use of short-lived tokens that would be retrieved automatically in GHA.

I might go the constantly-uploading route once I'm on hatch-vcs, but it seems like an enormous waste of PSF resources to store every main commit. :|

FWIW C-extension projects that have a ton of wheels hit the project limit in a year or two depending on the size, but it's not such a big problem for pure-python projects.

When you don't have an artifact upload job, you can't download the artifacts for inspection.

JFTR, this seems to be a thing among actions tho?
Because baipp puts the dist to /tmp/baipp and when I run an ls there, they are there: https://github.com/python-attrs/attrs/actions/runs/3732374577/jobs/6331733243#step:7:6
But for the action it's not: https://github.com/python-attrs/attrs/actions/runs/3732374577/jobs/6331733243#step:8:15

But for the action it's not

@hynek It is indeed unobvious… So I stared at the log for a good minute and then realized what was happening.
TL;DR It turned out to be unrelated to the use of artifacts, but rather the unpacking location.
GitHub allows making 3 types of actions: js-based, composite and docker-based. The two first ones are executed in the job VM runtime directly. But the docker actions are containerized, obviously. They have certain limitations, like being restricted to Linux-based runs-on. There are a number of directories that are mounted into the container when the action gets invoked (and there are also bypassed env vars, which created problems for us recently…)
Basically, the workdir, some temporary dirs and GHA framework/helper dirs are mounted but not /tmp. You can see the exact docker run command here: https://github.com/python-attrs/attrs/actions/runs/3732374577/jobs/6331733243#step:8:12.
The checkout directory also becomes an in-container workdir. This is why, setting a relative path for this action input works — it's in a mounted location.


Cachix: 1.3.3 -> 1.4

Fixes https://github.com/NixOS/nixpkgs/issues/188401
Note that pkgsStatic.cachix will build after haskell package set is updated.

Oh I see, this will require a patch for hercules-ci-agent.


Rs.exe is causing Windows Defender to report a threat and throws an exception.

It appears that rs.exe generates a temporary executable in the local temp folder, Windows Defender is blocking it and sometimes reporting it as a virus (Trojan:Win32/Wacatac.B!ml).   This just started happening on several of our development machines (located on different networks).  I am wondering if something changed in Windows Defender recently that is causing it to detect this (hopefully) false virus signature.  The file disappears right after rs.exe executes.  Also, a full scan of the machine runs clean.
rs -i PublishReports.rss -s http://localhost/ReportServer
Could not load file or assembly 'file:///C:\Users\mll\AppData\Local\Temp\myq1d4yg.exe' or one of its dependencies. Operation did not complete successfully because the file contains a virus or potentially unwanted software. (Exception from HRESULT: 0x800700E1)

Is there any progress in fixing this?
This is currently preventing updates in our customer's environment :/


Remove texts from legends

See #387 we remove them and they keep showing up.

See #387 we remove them and they keep showing up.

What do you mean? why is it showing up again?

I mean it's the 3rd patch that removes legends, I hope this is the last time


Response serialization

Response serialization for TRON 2.0.0 has undergone significant changes, and  is influencing experience with TRON.framework in a lot of ways. In this issue we wanted to highlight our goals and current ideas for response serialization.
Previously, ResponseParseable protocol looked like this:
public protocol ResponseParseable {
    init(data: NSData) throws
}

This approach allowed us to put ResponseParseable generic restriction on APIRequest, and gather information about how a model needs to be parsed, directly from a model type. However, it has major flows. First of, you can't create factory parser, that creates subclasses from a model. Second, you can't create protocol, that has several models conforming to it, and parse response to several model types. And third, you are forced to use a constructor, which is problematic for example for CoreData objects, that are not created using a constructor, but instead a created using a static method.
Now, in TRON 2.0.0-beta.2, we are trying a different approach, here's how response serialization protocol looks now:
public protocol Parseable {
    associatedtype ModelType

    func parse(_ data: Data) throws -> ModelType
}

And we are adding mandatory response serialization properties to each TRON request method, for example:
open func request<Model, ErrorModel>(_ path: String,
                      responseParser: @escaping APIRequest<Model,ErrorModel>.ResponseParser,
                      errorParser: @escaping APIRequest<Model,ErrorModel>.ErrorParser) -> APIRequest<Model,ErrorModel>

We are using generic typealiases to define ResponseParser closure like this:
public typealias ResponseParser = (Data) throws -> Model

This way you can directly set your own kind of parser and tweak it in any way. To maintain some form of backwards compatibility, we are adding convenience method for SwiftyJSON subspec users, that prefill response and errorParser with SwiftyJSONDecodable parsers like so:
open func request<Model: JSONDecodable, ErrorModel:JSONDecodable>(_ path: String) -> APIRequest<Model,ErrorModel>
    {
        return APIRequest(path: path, tron: self,
                          responseParser: { try JSONParser<Model>().parse($0) },
                          errorParser: { JSONErrorParser().parseError(fromRequest: $0.0, response: $0.1, data: $0.2, error: $0.3)})
    }

This is, of course, a huge change, and we want to involve community to discuss better approaches. We are releasing this form of response serialization in TRON 2.0.0-beta.2 for all of you to try it out and will be improving it towards 2.0.0 release.

Looks good. I second that.

After long thought, i decided to use Alamofire DataResponseSerializerProtocol and extend it to our needs:
public protocol ErrorHandlingDataResponseSerializerProtocol : DataResponseSerializerProtocol {
    associatedtype SerializedError
    var serializeError: (Alamofire.Result<SerializedObject>?,URLRequest?, HTTPURLResponse?, Data?, Error?) -> APIError<SerializedError> { get }
}

This allows us to do several things. First, we are able to use all request information to serialize response, not only data, that was received. Second, we are now constraining our generic Model and ErrorModel types to fit into those two protocols:
open func request<Model, ErrorModel, Serializer: ErrorHandlingDataResponseSerializerProtocol>
        (_ path: String, responseSerializer : Serializer) -> APIRequest<Model,ErrorModel>
        where Serializer.SerializedObject == Model, Serializer.SerializedError == ErrorModel
    {
        return APIRequest(path: path, tron: self, responseSerializer: responseSerializer)
    }

And third, we are now allowing to use any Alamofire custom response serializer with TRON directly just by adding some minor tweaks that specialize error type.


Exclude some long-running tests when running under miri

Which issue does this PR close?

Hopefully this makes the miri workflow in CI a bit more reliable.
Closes #1862.
Rationale for this change

What changes are included in this PR?

Are there any user-facing changes?

This did not seem to fix CI. Test tests still seem to get killed and then retried by miri.sh:
test compute::kernels::cast_utils::tests::string_to_timestamp_timezone_space ... ok
error: test failed, to rerun pass '-p arrow --lib'
Caused by:
  process didn't exit successfully: `/home/runner/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/cargo-miri /home/runner/work/arrow-rs/arrow-rs/target/miri/x86_64-unknown-linux-gnu/debug/deps/arrow-ca24f64806e3ede9 --skip csv --skip ipc --skip json` (exit status: 255)
test compute::kernels::comparison::tests::ilike_utf8_scalar_escape_testing ... Starting Arrow MIRI run...
    Finished test [unoptimized + debuginfo] target(s) in 0.38s
     Running unittests src/lib.rs (target/miri/x86_64-unknown-linux-gnu/debug/deps/arrow-ca24f64806e3ede9)
running 1038 tests
test array::array::tests::test_array_ref_as_array ... ok

error: test failed, to rerun pass '-p arrow --lib'
Caused by:
  process didn't exit successfully: `/home/runner/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/cargo-miri /home/runner/work/arrow-rs/arrow-rs/target/miri/x86_64-unknown-linux-gnu/debug/deps/arrow-ca24f64806e3ede9 --skip csv --skip ipc --skip json` (exit status: 255)
test compute::kernels::comparison::tests::ilike_utf8_scalar_escape_testing ... Miri finished with exit code 255

That's actually not the error code I expected if it is an out of memory issue

Disabling stacked-borrow checking is not perfect, but probably better to run miri with one less check than not running it at all. The check using a lot of cpu and memory is a known problem: https://github.com/rust-lang/miri/issues/1367


registered S3 Method overwritten by jsonify: print.json

Describe the bug
A clear and concise description of what the bug is.
To Reproduce
Please include a minimal reproducible example (AKA a reprex). If you've never heard of a reprex before, start by reading https://www.tidyverse.org/help/#reprex.
Expected behavior
A clear and concise description of what you expected to happen.
Additional context
Add any other context about the problem here.

This occurs when jsonlite is loaded before arcgislayers etc. and arc_select is used.
I wonder if we can prevent the printing method ever being used

I've removed the json class from all instances of jsonify::to_json() in arcgisutils. These are the only places I can think of where the object might get printed as a json class from jsonify. At the end of the day, there is no issue in this warning.
https://github.com/R-ArcGIS/arcgisutils/commit/53680c984acf411adf48c784e57e3db1e7e0da7a


port GenotypingEngine

part of HaplotypeCaller

includes MergeVariantsAcrossHaplotypes

depends on #731

required for #18

closed by ##917


Remove special hlx3 flag handling for known projects

When migrating the first projects to hlx3, we hardcoded known projects to always have hlx3=true in the sidekick config, so we didn't have to bother the authors to update their bookmarklets.
Since #14, this is no longer necessary, as hlx3 can now be defined centrally for projects. The hardcoded projects and corresponding logic should be removed from the sidekick again.

:tada: This issue has been resolved in version 3.5.0 :tada:
The release is available on GitHub release
Your semantic-release bot :package::rocket:


Possible to use multiple fonts in baffle characters?

I see that you can exclude certain characters from being obfuscated, however I was wondering if it's possible to use two different font's for the characters in options.fonts.
Right now I'm using the array of characters from the example, ["█", "▓", "▒", "░", "█", "▓", "▒", "░", "█", "▓", "▒", "░"] however I'd also like to include a single letter, but use a different from other characters as the unicode shade characters look ugly in the font i'm using for the letter.

@z-a-h Sorry for the late answer! That's something you'd probably want to handle with CSS. This library will only determine the characters used, not the fonts.


Nice to have: filter table by mutation list

Often I want to check in the table if a list of mutations (typical of a new variant) are there or not.
I now do it using CTRL+F on the browser, checking the present of mutations one by one.
Could it be possible to have a field, comma separated, where, e.g., I write
"S:S477N,S:T478K,S:E484A,S:Q493R,S:D614G,S:H655Y"
and it filters only these mutations in the table?

Maybe I can implement a more user-friendly filter like the one for proteins which allows to select multiple options.
What does it represent the value before the : ? Is it the protein?

Yes, I thought it was so.
By the way, the filter has been added in commit  4a55be94821e0867619e825d696668c8b5e04e89


Idea: input types with built-in transform

Sometimes you want to create multiple queries and mutations that all use the same input object and want to pass that to your orm, like prisma:
builder.queryField("project", (t) =>
  t.prismaField({
    type: "Project",
    args: {
      where: t.arg({
        required: true,
        type: ProjectWhereUniqeInputRef,
      }),
    },
    nullable: true,
    resolve: async (query, parent, { where }) => {
      return prisma.organisation.findUnique({
        ...query,
        where
      });
    },
  }),
);

builder.mutationField("updateProject", (t) =>
  t.prismaField({
    type: "Project",
    args: {
      data: ....
      where: t.arg({
        type: ProjectWhereUniqeInputRef,
        required: true,
      }),
    },
    resolve: async (query, parent, { data, where }) => {
      return prisma.project.update({
        data,
        where,
        ...query,
      });
    },
  }),
);

however, this requires that the backing type of ProjectWhereUniqeInputRef has the same shape as prisma requires as were.
If its not the same, you have to transform it, but you have to do that on each query:
builder.queryField("project", (t) =>
  t.prismaField({
    type: "Project",
    args: {
      where: t.arg({
        required: true,
        type: ProjectWhereUniqeInputRef,
      }),
    },
    nullable: true,
    resolve: async (query, parent, { where }) => {
      return prisma.organisation.findUnique({
        ...query,
        where: await transformProjectWhere(where) // transform
      });
    },
  }),
);

builder.mutationField("updateProject", (t) =>
  t.prismaField({
    type: "Project",
    args: {
      data: ....
      where: t.arg({
        type: ProjectWhereUniqeInputRef,
        required: true,
      }),
    },
    resolve: async (query, parent, { data, where }) => {
      return prisma.project.update({
        data,
        where: await transformProjectWhere(where),
        ...query,
      });
    },
  }),
);

this is of course doable, but can be a bit awkward.
An elegant solution would be that ProjectWhereUniqeInputRef would already do this transformation:
type InputShape = {
  tenantId: string,
  slug: string
}

type TransformedInputShape = {
   tenantId_slug: { // bit a trivial example, but e.g. to "hide" those combined id keys
     tenantId: string,
     slug: string
   }
}
export const ProjectWhereUniqueInputRef = builder
  .inputRef<InputShape, TransformedInputShape>("ProjectWhereUniqueInput")
  .implement({
    fields: (t) => ({
      tenantId: t.string({
        required: true,
      }),
      slug: t.string({
        required: true,

      }),
    }),
transform: (input /* has InputShape */) => { // can be async function as well
     return { // has to return TransformedInputShape
         tenantId_slug: {slug: input.slug, tenantId: input.tenantId}
      }
   }
  });

so wherever you use ProjectWhereUniqueInputRef in an argument, the object has the TransformedInputShape in the resolver instead of InputShape

We probably won't be able to add this to pothos/core, but something similar should be achievable through a plugin.
There are existing mechanism in pothos that allow plugins to transform inputs.  The API would likely be something like const InputRef =  builder.inputRef(...).transform((data) => transformData(data).
I have been intending to implement a new validation plugin that works this way (the biggest drawback of the zod plugin was the lack of transforms).  The goal would be to support arbitrary validations + transforms without being tied to a specific validation library.
Implementing a plugin that just handles transformations would be relatively easy.  I can try to find some time this weekend to put together a quick prototype that you can use to add that as a custom plugin

that sounds good, a plugin would be good enough

Here's a basic transform plugin you can use/modify to fit your use-case
import { createServer } from 'node:http';
import type { PothosOutputFieldConfig, SchemaTypes } from '@pothos/core';
import SchemaBuilder, {
  BasePlugin,
  createInputValueMapper,
  InputObjectRef,
  mapInputFields,
  resolveInputTypeConfig,
} from '@pothos/core';
import { createYoga } from 'graphql-yoga';

declare global {
  namespace PothosSchemaTypes {
    export interface InputObjectRef<Types extends SchemaTypes, T> {
      transform: <U>(fn: (value: T) => U) => InputObjectRef<Types, U>;
    }

    export interface Plugins<Types extends SchemaTypes> {
      transformInputs: TransformInputsPlugin<Types>;
    }
  }
}

InputObjectRef.prototype.transform = function (
  this: InputObjectRef<SchemaTypes, unknown>,
  fn: (value: unknown) => unknown,
) {
  this.updateConfig((config) => {
    return {
      ...config,
      extensions: {
        ...config.extensions,
        inputTransformFunctions: [
          ...((config.extensions?.inputTransformFunctions as []) ?? []),
          fn,
        ],
      },
    };
  });

  return this;
};

export class TransformInputsPlugin<Types extends SchemaTypes> extends BasePlugin<Types> {
  override onOutputFieldConfig(
    fieldConfig: PothosOutputFieldConfig<Types>,
  ): PothosOutputFieldConfig<Types> | null {
    const argMappings = mapInputFields(fieldConfig.args, this.buildCache, (inputField) => {
      let inputTypeConfig: ReturnType<typeof resolveInputTypeConfig> | null;
      try {
        inputTypeConfig = resolveInputTypeConfig(inputField.type, this.buildCache);
      } catch (_) {
        inputTypeConfig = null;
      }

      if (inputTypeConfig?.extensions?.inputTransformFunctions) {
        return (input: unknown) =>
          input == null
            ? input
            : (
                inputTypeConfig.extensions?.inputTransformFunctions as ((
                  value: unknown,
                ) => unknown)[]
              ).reduce<unknown>((acc, fn) => fn(acc), input);
      }

      return null;
    });

    if (!argMappings) {
      return fieldConfig;
    }

    const argMapper = createInputValueMapper(argMappings, (value, mapping) =>
      mapping.value ? mapping.value(value) : value,
    );

    return {
      ...fieldConfig,
      argMappers: [...(fieldConfig.argMappers ?? []), (args) => argMapper(args)],
    };
  }
}

SchemaBuilder.registerPlugin('transformInputs', TransformInputsPlugin);

const builder = new SchemaBuilder<{}>({
  plugins: ['transformInputs'],
});

const TransformedInput = builder
  .inputType('ToTransform', {
    fields: (t) => ({
      value: t.string({ required: true }),
    }),
  })
  .transform(({ value }) => ({
    number: Number.parseInt(value, 10),
  }));

builder.queryType({
  fields: (t) => ({
    test: t.int({
      args: {
        input: t.arg({
          required: true,
          type: TransformedInput,
        }),
        inputList: t.arg({
          required: true,
          type: [TransformedInput],
        }),
      },
      resolve: (_, args) => {
        console.log(args);
        return args.inputList.reduce((a, b) => a + b.number, args.input.number);
      },
    }),
  }),
});

const yoga = createYoga({
  schema: builder.toSchema(),
  maskedErrors: false,
});

const server = createServer(yoga);

const port = 3000;
server.listen(port);

Here's a basic transform plugin you can use/modify to fit your use-case
import { createServer } from 'node:http';
import type { PothosOutputFieldConfig, SchemaTypes } from '@pothos/core';
import SchemaBuilder, {
  BasePlugin,
  createInputValueMapper,
  InputObjectRef,
  mapInputFields,
  resolveInputTypeConfig,
} from '@pothos/core';
import { createYoga } from 'graphql-yoga';

declare global {
  namespace PothosSchemaTypes {
    export interface InputObjectRef<Types extends SchemaTypes, T> {
      transform: <U>(fn: (value: T) => U) => InputObjectRef<Types, U>;
    }

    export interface Plugins<Types extends SchemaTypes> {
      transformInputs: TransformInputsPlugin<Types>;
    }
  }
}

InputObjectRef.prototype.transform = function (
  this: InputObjectRef<SchemaTypes, unknown>,
  fn: (value: unknown) => unknown,
) {
  this.updateConfig((config) => {
    return {
      ...config,
      extensions: {
        ...config.extensions,
        inputTransformFunctions: [
          ...((config.extensions?.inputTransformFunctions as []) ?? []),
          fn,
        ],
      },
    };
  });

  return this;
};

export class TransformInputsPlugin<Types extends SchemaTypes> extends BasePlugin<Types> {
  override onOutputFieldConfig(
    fieldConfig: PothosOutputFieldConfig<Types>,
  ): PothosOutputFieldConfig<Types> | null {
    const argMappings = mapInputFields(fieldConfig.args, this.buildCache, (inputField) => {
      let inputTypeConfig: ReturnType<typeof resolveInputTypeConfig> | null;
      try {
        inputTypeConfig = resolveInputTypeConfig(inputField.type, this.buildCache);
      } catch (_) {
        inputTypeConfig = null;
      }

      if (inputTypeConfig?.extensions?.inputTransformFunctions) {
        return (input: unknown) =>
          input == null
            ? input
            : (
                inputTypeConfig.extensions?.inputTransformFunctions as ((
                  value: unknown,
                ) => unknown)[]
              ).reduce<unknown>((acc, fn) => fn(acc), input);
      }

      return null;
    });

    if (!argMappings) {
      return fieldConfig;
    }

    const argMapper = createInputValueMapper(argMappings, (value, mapping) =>
      mapping.value ? mapping.value(value) : value,
    );

    return {
      ...fieldConfig,
      argMappers: [...(fieldConfig.argMappers ?? []), (args) => argMapper(args)],
    };
  }
}

SchemaBuilder.registerPlugin('transformInputs', TransformInputsPlugin);

const builder = new SchemaBuilder<{}>({
  plugins: ['transformInputs'],
});

const TransformedInput = builder
  .inputType('ToTransform', {
    fields: (t) => ({
      value: t.string({ required: true }),
    }),
  })
  .transform(({ value }) => ({
    number: Number.parseInt(value, 10),
  }));

builder.queryType({
  fields: (t) => ({
    test: t.int({
      args: {
        input: t.arg({
          required: true,
          type: TransformedInput,
        }),
        inputList: t.arg({
          required: true,
          type: [TransformedInput],
        }),
      },
      resolve: (_, args) => {
        console.log(args);
        return args.inputList.reduce((a, b) => a + b.number, args.input.number);
      },
    }),
  }),
});

const yoga = createYoga({
  schema: builder.toSchema(),
  maskedErrors: false,
});

const server = createServer(yoga);

const port = 3000;
server.listen(port);

thank you very much, i'll try that out

@hayes i tried it, unfortunatly, it does not work with async function, or at least, not directly.
you have to await the argument in your resolver.
i tried to see whether I can fix this in the plugin, but it looks like this is deep down in pothos core where the mapper is called and i did not see whether you can resolve the promise somewhere there

I would be very hesitant to add a sync input transforms into Pothos. What kinds of transforms are you doing that require async calls?
The argument mappers are used in paces that can't easily be made async. You can definitely handle async mapping in a custom plugin, but you would need to use the wrapResolver hook, and not use the built-in arg mapper.

the transform require and additional db request in my case.
Since you mentioned validation as use case, I am pretty sure a common request will be for async validation 😉
isn't the mapper also using the wrapResolver?


[fix][broker] Fix getPositionAfterN infinite loop.

Fixes #17967
Master Issue: #17967
Motivation
The root cause is here(line-3365)  :
https://github.com/apache/pulsar/blob/08f5766d95034ce27c44ee30e4734d2a8f078e11/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerImpl.java#L3364-L3366
The currentLedgerId should be :
currentLedgerId = lid != null ? lid : (ledgers.lastKey());

Documentation

[ ] doc
[ ] doc-required
[x] doc-not-needed
[ ] doc-complete

Matching PR in forked repository
PR in forked repository: https://github.com/Technoboy-/pulsar/pull/9

Great catch!
Is it able to add an unit test?

We already have the test testGetPositionAfterN

We already have the test testGetPositionAfterN

@Technoboy- So why did the test get passed before? I think the test can't cover the case that introduce the infinite loop?

We already have the test testGetPositionAfterN

@Technoboy- So why did the test get passed before? I think the test can't cover the case that introduces the infinite loop?

Ah, yes, right.  Sorry for this.   I have added the test.

@Technoboy- Please check the failed test

@Technoboy- Please check the failed test

Yes, I have fixed by https://github.com/apache/pulsar/pull/17993

Codecov Report

:exclamation: No coverage uploaded for pull request base (master@7e420c6). Click here to learn what that means.
The diff coverage is n/a.

@@            Coverage Diff            @@
##             master   #17971   +/-   ##
=========================================
  Coverage          ?   26.91%
  Complexity        ?     3523
=========================================
  Files             ?      393
  Lines             ?    43418
  Branches          ?     4462
=========================================
  Hits              ?    11687
  Misses            ?    29893
  Partials          ?     1838

Flag
Coverage Δ

unittests
26.91% <0.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.


Promotion

Places we've targeted

[x] personal networks
[x] codebar cambridge
[ ] Women in tech communities on twitter (@DjangoGirls @WWCLondon @DevelopHerUK @girl_geeks)

@yochannah other places you suggest we push?

I've shared it in the RSE UK slack group. I'm wracking my brains for other places to share and will add if they come up!

[ ] OpenConCam mailing list?

Good shout. Are you on that? If so, would you mind doing it? Bit of a conflict right now as we're in final push for promoting eLife Sprint, so don't want to confuse anyone with lots of emails from me.

Yup, will do
On 27 Feb 2018 20:19, "Naomi Penfold"<EMAIL_ADDRESS>wrote:

Good shout. Are you on that? If so, would you mind doing it? Bit of a
conflict right now as we're in final push for promoting eLife Sprint, so
don't want to confuse anyone with lots of emails from me.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/open-data-day-cambridge-2018/open-data-day-cambridge-2018.github.io/issues/13#issuecomment-369012437,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AI14jtx4Fq5Lyp9ahnAjJOu0TO5oqL95ks5tZGM6gaJpZM4SU2aD
.


Convert to DSCResource.Common - Fixes #685

Pull Request (PR) description
Convert module to use DSCResource.Common. This also improves integration test reliability by adding Reset-DscLcm.
This Pull Request (PR) fixes the following issues

Fixes #685
Fixes #652
Fixes #686

Task list

[x] Added an entry to the change log under the Unreleased section of the
file CHANGELOG.md. Entry should say what was changed and how that
affects users (if applicable), and reference the issue being resolved
(if applicable).
[ ] Resource documentation added/updated in README.md.
[ ] Resource parameter descriptions added/updated in README.md, schema.mof
and comment-based help.
[ ] Comment-based help added/updated.
[ ] Localization strings added/updated in all localization files as appropriate.
[ ] Examples appropriately added/updated.
[x] Unit tests added/updated. See DSC Community Testing Guidelines.
[ ] Integration tests added/updated (where possible). See DSC Community Testing Guidelines.
[ ] New/changed code adheres to DSC Community Style Guidelines.

This change is

@johlju - would you mind reviewing this one when you have time?


Font isn't loading on deployment

The Inter font seems to work in local testing. But on https://beta.fluthub.com it seems to not load.

@barthalion I guess it's due to the font being on another domain? can we move it into this repo and just use it from here?
https://stackoverflow.com/questions/19817459/firefox-font-face-with-local-file-downloadable-font-download-failed

It definitely works for me.

We also set access-control-allow-origin * to make sure any domain can fetch it.

Works for me now, not sure why. Previously I got this on every load.

Your right, you can force it with Control + F5

For whatever reason i am still getting downloadable font: font-display timeout, webfont not used (font-family: "Inter" style:normal weight:400 stretch:100 src index:0) source: https://dl.flathub.org/repo/assets/Inter-3.19/Inter-Regular.woff2 from time to time. Can't we just ship the font as part of the assets?

This is not going to change anything, as loading the font will still not finish within 100ms which browser use as the time limit. It will be even slower as it will served from UK instead from your closest CDN host.

actually never mind, the error is not about not being able to download the font at all...


Referenced Component can not be used in a cascading value

When using a combination of both a component reference and cascading value, that value is not sent to child elements
Example
@inherits BlazorLayoutComponent

    <NavMenu/>

<Modal ref="modalTest"/>

    <CascadingValue Value="@modalTest">

            @Body

    </CascadingValue>

@functions
{
    Modal modalTest;
}

When accessing the modal in the following component, I am always getting a null reference exception
@page "/Admin"
@inject HttpClient Http

Students

@functions
{
    IList<Models.Student> _students;

    [CascadingParameter] Modal _modal { get; set; }

    protected override async Task OnInitAsync()
    {
        _students = await Http.GetJsonAsync<IList<Models.Student>>("api/Student/GetStudentsWithGoalsAndAvailableAnswers");
    }

    protected override void OnAfterRender()
    {
        _modal.ElementId = "This is a test";
    }
}

The only thing that would not make this throw an error was to define the modal in the following way in the layout Modal modalTest = new Modal

In the doc (https://blazor.net/docs/components/index.html#capture-references-to-components) we can read

The loginDialog variable is only populated after the component is rendered and its output includes the MyLoginDialog element because until then there is nothing to reference.

In the example (which is very similar to your source code) we have two components: the component we are currently working on (let's name it main component) and MyLoginDialog component (child component). The sentence from the doc could probably be written as:
The loginDialog variable is only populated after the main component is rendered and its output includes the MyLoginDialog element (child component) because until then there is nothing to reference.
I think your program works "correctly" - that is null reference exception is expected in this case.
Of course this is not good. Component references are available since Blazor 0.3, while cascading values were added in 0.7.
@SteveSandersonMS maybe it is possible to change the design and initialize reference variable immediately after the child component is rendered. @ckbeatty's source code is very similar to your TabSet example - he needs reference to some component in all child components. Your program works because you are passing this as cascading value. @ckbeatty is trying to pass a reference to Modal from main layout. This is recommended in Bootstrap doc:

Whenever possible, place your modal HTML in a top-level position to avoid potential interference from other elements. You’ll likely run into issues when nesting a .modal within another fixed element.

Interestingly the example works if you define Modal and CascadingValue at the page level (in Index.cshtml) instead of at the layout level.  It's not as convenient as in MainLayout but it does work on my machine.
I checked the codebase, and I can see that the LayoutComponent's body gets rendered first and then the layout gets rendered with the pre-rendered body getting inserted into it, LayoutDisplay.cs.  So yeah, like you pointed out @Andrzej-W, the modal wouldn't have been rendered yet if it's defined in the Layout.
I wonder if there's any reason Blazor couldn't render the Layout first and then insert it's body?

Interesting discovery @andoband. Hopefully LayoutComponet can be corrected and it will work exactly as page level component.
English is not my native language and I know it rather poorly but in my humble opinion documentation is currently also not 100% correct. According to @andoband's experiment child component reference is available (at least sometimes) during rendering and not only after the main component is rendered.

IMPORTANT
The loginDialog variable is only populated after the component is rendered and its output includes the MyLoginDialog element because until then there is nothing to reference. To manipulate components references after the component has finished rendering, use the OnAfterRenderAsync or OnAfterRender lifecycle methods.


Update basic view designs with similar components of BCP pages

Description:
This ticket is to make a couple small updates to align the basic RST page view with some BCP components (both built in React).
https://www.figma.com/design/TFDtavdpJE2vrB5vEmBB6w/RST---Basic-View?node-id=0-1&node-type=canvas&t=PKda1I7RZCJ6r7Kq-0
Continue to keep the designs very simple but show some alignment with BCP layout.
Acceptance Criteria:

[x] complete items in design checklist below
[x] updated designs are added to #24

Design Checklist:

[x] Image section to look more like BCP pages
[x] Activity icons are added to activity list
[x] Specify Rec Site or Trail (but keep page basically the same for now)
[x] Map placeholder

Notes:

driven by inputting recsite number into url for driving to site

nice! moving to done and will unblock the implementation ticket :)


parser not able to parse nested code

The parser is having a really hard time parsing and validating this page
---
import { Code } from 'astro/components';

---

{"About"}
<Code code={`
---
import { localizePath } from "astro-i18next";
import i18next, { t } from "i18next";
import { Button } from "@ui";
import Home from "@/components/home";
import LanguageSelector from<EMAIL_ADDRESS>---

{t("welcome.title")}

<Home client:load />

<LanguageSelector showFlag={true} />
<Button />

  {i18next.format(t("about"), "capitalize")}
`} lang="js" theme="dark-plus" />

I can't reproduce your problem. Please provide a minimal repository to reproduce the problem.


[Request for External] page 2901 "Demand Forecast Card"

hi,
please switch the procedure to global
    local procedure SetMatrix()
please switch the variables to protected
    var
        MatrixRecords: array[32] of Record Date;
        VariantFilterIsEnabled: Boolean;
        LocationFilterIsEnabled: Boolean;
        IsEditable: Boolean;
        ItemFilter: Text;
        LocationFilter: Text;
        VariantFilter: Text;
        MatrixColumnCaptions: array[32] of Text[1024];
        ColumnSet: Text;
        PKFirstRecInCurrSet: Text;
        CurrentSetLength: Integer;

It would be really great if this requirement will be shipped with BC20. (Next minor)
I can not wait to the next major. :(
Thanks!

Thanks for reporting this. We agree, and we’ll publish a fix asap, either in an update for the current version or in the next major release. Please do not reply to this, as we do not monitor closed issues. If you have follow-up questions or requests, please create a new issue where you reference this one.


Can't assign headers from late array set in initState.

I followed example and I'm getting error in headers field:
A value of type 'Null' can't be assigned to a parameter of type 'List' in a const constructor.
Try using a subtype, or removing the keyword 'const'.dartconst_constructor_param_type_mismatch
Invalid constant value.dart(invalid_constant)

My bad, IDE added const to top Card widget.


E154: Duplicate tag "vim-fetch" in file .../vim-fetch/doc/vim-fetch.txt

If I add Plugin "kopische/vim-fetch to my .vimrc, source it, and run :PluginInstall, it reports an error while running helptags.
If I run :helptags ~/.vim/bundle/kopische/vim-fetch/, I get
E154: Duplicate tag "vim-fetch" in file /home/mg/.vim/bundle/vim-fetch/doc/vim-fetch.txt
E154: Duplicate tag "vim-fetch" in file /home/mg/.vim/bundle/vim-fetch/doc/vim-fetch.txt
E154: Duplicate tag "vim-fetch" in file /home/mg/.vim/bundle/vim-fetch/doc/vim-fetch.txt
E154: Duplicate tag "vim-fetch" in file /home/mg/.vim/bundle/vim-fetch/doc/vim-fetch.txt

Yeah, my bad: I had a brainfart and tried to use Markdown italics. Will fix ASAP.

@mgedmin fixed in latest release. Thanks for reporting!

Thank you for the very quick fix!


AttributeError: 'ArrayBox' object has no attribute 'exp'

Hi everyone,
I'm implementing an alpha-divergence minimisation algorithm with a pretty simple loss function that I need to differentiate. The problem, it seems, is that the function contains exp and log, which should be totally fine.
Moreover, if I isolate the exponential or the logarithm function I can compute its gradient normally, so I guess the problem may be in the context of my loss function.
The code looks like this:
def wake_sleep(inputs, inputs_f, S, theta, alpha):
    nn_params = [1e-1, [1, 10, 10, 1]]
    z = [init_random_params(nn_params) for _ in range(S)]
    init_theta = theta

    def bb_alpha_energy(theta, t):
        print(theta)
        m_a, s_a, sigma = theta
        a = np.random.normal(size=(S, S)) * s_a + m_a
        m_qgp = 1. / S * np.sum([g_nn(inputs, z_i) for z_i in z], axis=0)

        mc_q = []
        for a_k in a:
            m_k = []
            for z_s, a_s in zip(z, a_k):
                m_k.append((g_nn(inputs_f, z_s) - m_qgp) * a_s)
            m = (1. / np.sqrt(S - 1) * np.sum(m_k, axis = 0))
            mc_q.append(gaussian_pdf(inputs_f, m, sigma)**alpha)
        mc_q = np.mean(mc_q, axis = 0)

        alpha_energy = 1. / alpha * np.sum(np.log(mc_q)) - kl(m_a, s_a, 0., 1.)
        return alpha_energy

    grad_loss = grad(bb_alpha_energy)
    opt_theta = adam(grad_loss, init_theta, step_size=0.01, num_iters=500)
    return opt_theta

The failure occurs when the tracer goes through mc_q.append(gaussian_pdf(inputs_f, m, sigma)**alpha).
May it be because I'm mixing vector-output functions (such as gaussian_pdf) with my scalar-output function? How should I go about this?
Thank you,
Alex

What failure occurs?  What is the error message?
As a side note, you almost certainly should use log pdfs, and sum them using logsumexp:
https://docs.scipy.org/doc/scipy-0.14.0/reference/generated/scipy.misc.logsumexp.html
if you want to avoid numerical underflow.

This is the error message, it's quite long so I only put the title. I'll use log pdfs, thanks!
AttributeError                            Traceback (most recent call last)
<ipython-input-24-f409b4ff2e6f> in <module>()
    109     alpha = 1.
    110
--> 111     opt_theta = wake_sleep(x, f_x, S, init_theta, alpha)
    112     print(opt_theta)
    113

<ipython-input-24-f409b4ff2e6f> in wake_sleep(inputs, inputs_f, S, theta, alpha, grad_loss)
     92     if grad_loss is None:
     93         grad_loss = grad(bb_alpha_energy)
---> 94     opt_theta = adam(grad_loss, init_theta, step_size=0.01, num_iters=500)
     95     return opt_theta
     96

~/.anaconda/lib/python3.6/site-packages/autograd/misc/optimizers.py in _optimize(grad, x0, callback, *args, **kwargs)
     26         else:
     27             _callback = None
---> 28         return unflatten(optimize(_grad, _x0, _callback, *args, **kwargs))
     29
     30     return _optimize

~/.anaconda/lib/python3.6/site-packages/autograd/misc/optimizers.py in adam(grad, x, callback, num_iters, step_size, b1, b2, eps)
     62     v = np.zeros(len(x))
     63     for i in range(num_iters):
---> 64         g = grad(x, i)
     65         if callback: callback(x, i, g)
     66         m = (1 - b1) * g      + b1 * m  # First  moment estimate.

~/.anaconda/lib/python3.6/site-packages/autograd/misc/optimizers.py in <lambda>(x, i)
     21     def _optimize(grad, x0, callback=None, *args, **kwargs):
     22         _x0, unflatten = flatten(x0)
---> 23         _grad = lambda x, i: flatten(grad(unflatten(x), i))[0]
     24         if callback:
     25             _callback = lambda x, i, g: callback(unflatten(x), i, unflatten(g))

~/.anaconda/lib/python3.6/site-packages/autograd/wrap_util.py in nary_f(*args, **kwargs)
     18             else:
     19                 x = tuple(args[i] for i in argnum)
---> 20             return unary_operator(unary_f, x, *nary_op_args, **nary_op_kwargs)
     21         return nary_f
     22     return nary_operator

~/.anaconda/lib/python3.6/site-packages/autograd/differential_operators.py in grad(fun, x)
     22     arguments as `fun`, but returns the gradient instead. The function `fun`
     23     should be scalar-valued. The gradient has the same type as the argument."""
---> 24     vjp, ans = _make_vjp(fun, x)
     25     if not vspace(ans).size == 1:
     26         raise TypeError("Grad only applies to real scalar-output functions. "

~/.anaconda/lib/python3.6/site-packages/autograd/core.py in make_vjp(fun, x)
      8 def make_vjp(fun, x):
      9     start_node = VJPNode.new_root(x)
---> 10     end_value, end_node =  trace(start_node, fun, x)
     11     if end_node is None:
     12         def vjp(g): return vspace(x).zeros()

~/.anaconda/lib/python3.6/site-packages/autograd/tracer.py in trace(start_node, fun, x)
      8     with trace_stack.new_trace() as t:
      9         start_box = new_box(x, t, start_node)
---> 10         end_box = fun(start_box)
     11         if isbox(end_box) and end_box._trace == start_box._trace:
     12             return end_box._value, end_box._node

~/.anaconda/lib/python3.6/site-packages/autograd/wrap_util.py in unary_f(x)
     13                 else:
     14                     subargs = subvals(args, zip(argnum, x))
---> 15                 return fun(*subargs, **kwargs)
     16             if isinstance(argnum, int):
     17                 x = args[argnum]

<ipython-input-24-f409b4ff2e6f> in bb_alpha_energy(theta, t)
     83                 m_k.append((g_nn(inputs_f, z_s) - m_qgp) * a_s)
     84             m = (1. / np.sqrt(S - 1) * np.sum(m_k, axis=0))
---> 85             mc_q.append(gaussian_pdf(inputs_f, m, sigma)**alpha)
     86         mc_q = np.mean(mc_q, axis=0)
     87

<ipython-input-24-f409b4ff2e6f> in gaussian_pdf(x, mean, sigma)
     69         return 1. / (
     70             np.sqrt(2 * np.pi) * sigma) * np.exp(-0.5 *
---> 71                                                  (x - mean)**2 / sigma**2)
     72
     73     def bb_alpha_energy(theta, t):

~/.anaconda/lib/python3.6/site-packages/autograd/tracer.py in f_wrapped(*args, **kwargs)
     42             parents = tuple(box._node for _     , box in boxed_args)
     43             argnums = tuple(argnum    for argnum, _   in boxed_args)
---> 44             ans = f_wrapped(*argvals, **kwargs)
     45             node = node_constructor(ans, f_wrapped, argvals, kwargs, argnums, parents)
     46             return new_box(ans, trace, node)

~/.anaconda/lib/python3.6/site-packages/autograd/tracer.py in f_wrapped(*args, **kwargs)
     46             return new_box(ans, trace, node)
     47         else:
---> 48             return f_raw(*args, **kwargs)
     49     f_wrapped.fun = f_raw
     50     f_wrapped._is_autograd_primitive = True

AttributeError: 'ArrayBox' object has no attribute 'exp'```

Are you using import numpy as np? If so change to import autograd.numpy as np.

No I’m not. I knew that could be the reason but it’s not the case.
On 5 Jul 2018, 3:06 PM +0100, Jamie Townsend<EMAIL_ADDRESS>wrote:

Are you using import numpy as np? If so change to import autograd.numpy as np.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.

Could you provide the full code to reproduce the error?

Yes sure!
import autograd.numpy as np
from autograd import grad
from autograd.misc.optimizers import adam
from autograd.scipy.misc import logsumexp
import autograd.numpy.random as npr

def init_random_params(theta, rs=npr.RandomState(0)):
    scale, layer_sizes = theta
    return [
        (
            rs.randn(insize, outsize) * scale,  # weight matrix
            rs.randn(outsize) * scale)  # bias vector
        for insize, outsize in zip(layer_sizes[:-1], layer_sizes[1:])
    ]

def g_nn(inputs, params, nonlinearity=np.tanh):
    for W, b in params:
        outputs = np.dot(inputs, W) + b
        inputs = nonlinearity(outputs)
    return outputs

def kl(m1, s1, m2, s2):
    return np.log(s2 / s1) + (s1**2 + (m1 - m2)**2) / (2 * s2**2) - 0.5

def wake_sleep(inputs, inputs_f, S, theta, alpha, grad_loss=None):
    nn_params = [1e-1, [1, 10, 10, 1]]
    z = [init_random_params(nn_params) for _ in range(S)]
    init_theta = theta

    def gaussian_pdf(x, mean, sigma):
        return 1. / (
            np.sqrt(2 * np.pi) * sigma) * np.exp(-0.5 *
                                                 (x - mean)**2 / sigma**2)

    def gaussian_logpdf(x, mean, sigma):
        return -np.log(2 * np.pi) - np.log(sigma) - 0.5 * (
            x - mean)**2 / sigma**2

    def bb_alpha_energy(theta, t):
        print(theta)
        m_a, s_a, sigma = theta
        a = np.random.normal(size=(S, S)) * s_a + m_a
        m_qgp = 1. / S * np.sum([g_nn(inputs, z_i) for z_i in z], axis=0)

        mc_q = []
        for a_k in a:
            m_k = []
            for z_s, a_s in zip(z, a_k):
                m_k.append((g_nn(inputs, z_s) - m_qgp) * a_s)
            m = (1. / np.sqrt(S - 1) * np.sum(m_k, axis=0))
            mc_q.append(gaussian_logpdf(inputs_f, m, sigma)**alpha)
        mc_q = 1. / S * np.log(np.sum(np.exp(mc_q), axis=0))

        alpha_energy = 1. / alpha * np.sum(mc_q) - kl(m_a, s_a, 0., 1.)
        return alpha_energy

    if grad_loss is None:
        grad_loss = grad(bb_alpha_energy)
    opt_theta = adam(grad_loss, init_theta, step_size=0.01, num_iters=500)
    return opt_theta

if __name__ == '__main__':
    x = np.random.normal(size=(300, 1))
    f_x = np.cos(5 * x) / (np.abs(x) + 1)
    y = f_x + np.random.normal(scale=1e-1)

    m_a = np.random.normal(loc=0, scale=1e-2)
    s_a = 1e-1
    s = 1e-1
    init_theta = [m_a, s_a, s]

    S = 20
    alpha = 1.

    opt_theta = wake_sleep(x, f_x, S, init_theta, alpha)
    print(opt_theta)

OK, thanks. Our support for nested data structures (here you've got arrays inside lists) isn't great, and you need to explicitly cast the lists to arrays in order for things to work. I've added the necessary casting and the following seems to work fine (although there appears to be some kind of numerical issue as it produces NaNs after a few iterations...
import autograd.numpy as np
from autograd import grad
from autograd.misc.optimizers import adam
from autograd.scipy.misc import logsumexp
import autograd.numpy.random as npr

def init_random_params(theta, rs=npr.RandomState(0)):
    scale, layer_sizes = theta
    return [
        (
            rs.randn(insize, outsize) * scale,  # weight matrix
            rs.randn(outsize) * scale)  # bias vector
        for insize, outsize in zip(layer_sizes[:-1], layer_sizes[1:])
    ]

def g_nn(inputs, params, nonlinearity=np.tanh):
    for W, b in params:
        outputs = np.dot(inputs, W) + b
        inputs = nonlinearity(outputs)
    return outputs

def kl(m1, s1, m2, s2):
    return np.log(s2 / s1) + (s1**2 + (m1 - m2)**2) / (2 * s2**2) - 0.5

def wake_sleep(inputs, inputs_f, S, theta, alpha, grad_loss=None):
    nn_params = [1e-1, [1, 10, 10, 1]]
    z = [init_random_params(nn_params) for _ in range(S)]
    init_theta = theta

    def gaussian_pdf(x, mean, sigma):
        return 1. / (
            np.sqrt(2 * np.pi) * sigma) * np.exp(-0.5 *
                                                 (x - mean)**2 / sigma**2)

    def gaussian_logpdf(x, mean, sigma):
        return -np.log(2 * np.pi) - np.log(sigma) - 0.5 * (
            x - mean)**2 / sigma**2

    def bb_alpha_energy(theta, t):
        print(theta)
        m_a, s_a, sigma = theta
        a = np.random.normal(size=(S, S)) * s_a + m_a
        m_qgp = 1. / S * np.sum([g_nn(inputs, z_i) for z_i in z], axis=0)

        mc_q = []
        for a_k in a:
            m_k = []
            for z_s, a_s in zip(z, a_k):
                m_k.append((g_nn(inputs, z_s) - m_qgp) * a_s)
            m = (1. / np.sqrt(S - 1) * np.sum(np.array(m_k), axis=0))
            mc_q.append(gaussian_logpdf(inputs_f, m, sigma)**alpha)
        mc_q = 1. / S * np.log(np.sum(np.exp(np.array(mc_q)), axis=0))

        alpha_energy = 1. / alpha * np.sum(mc_q) - kl(m_a, s_a, 0., 1.)
        return alpha_energy

    if grad_loss is None:
        grad_loss = grad(bb_alpha_energy)
    opt_theta = adam(grad_loss, init_theta, step_size=0.01, num_iters=500)
    return opt_theta

if __name__ == '__main__':
    x = np.random.normal(size=(300, 1))
    f_x = np.cos(5 * x) / (np.abs(x) + 1)
    y = f_x + np.random.normal(scale=1e-1)

    m_a = np.random.normal(loc=0, scale=1e-2)
    s_a = 1e-1
    s = 1e-1
    init_theta = [m_a, s_a, s]

    S = 20
    alpha = 1.

    opt_theta = wake_sleep(x, f_x, S, init_theta, alpha)
    print(opt_theta)

@jdcpni are you doing import numpy as np or import autograd.numpy as np? You need to do the latter for this to work...

Thanks for your quick response.
I have import autograd.numpy as np both in the module that calls the function and the one in which it is defined (i.e., from which the code fragment I sent you was taken).  I’m not sure the former  is necessary for present purposes, but mention it just in case, and also because there are calls to np in that other module that seem to work fine.
jdc

On Oct 19, 2018, at 4:35 AM, Jamie Townsend<EMAIL_ADDRESS>wrote:
@jdcpni https://github.com/jdcpni are you doing import numpy as np or import autograd.numpy as np? You need to do the latter for this to work...
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub https://github.com/HIPS/autograd/issues/416#issuecomment-431288408, or mute the thread https://github.com/notifications/unsubscribe-auth/AKR1GGXcnmAGMc_o9U3R5QmOYsHdDlf8ks5umY7ggaJpZM4VCqme.

Just a naive question. What about doing
np.numpy_boxes.ArrayBox.exp = lambda s: np.numpy_boxes.ArrayBox(
    value = np.exp(s._value),
    trace = s._trace,
    node  = s._node
)

?

Hi @j-towns
Just a naive question. What about doing
np.numpy_boxes.ArrayBox.exp = lambda s: np.numpy_boxes.ArrayBox(
    value = np.exp(s._value),
    trace = s._trace,
    node  = s._node
)

?

我也遇到了类似的问题，使用了几行简单得多的代码。下列：
def function(self, variable=None): result = np.exp(variable) return result
生成错误消息：
result = np.exp(variable)

AttributeError：“ ArrayBox”对象没有属性“ exp”
但是，只需将对np.exp的调用替换为
def function(self, variable=None): from math import e result = e**(variable) return result
运行良好。

how about the log()
the same issue.

I have same issue. Is there workaround for np.log()
Please help.
Thanks


Import-PowerShellDataFile Errors on files over 3230 lines

Steps to reproduce

Create a .psd1 file with 3231 lines in it.
Attempt to import with Import-PowerShellDataFile. It should fail stating that there is a dynamic ScriptBlock.
Delete one line from the file. It should import successfully.

Expected behavior
> Import-PowerShellDataFile -Path largeConfiguration.psd1
No Error just results

Actual behavior
> Import-PowerShellDataFile -Path largeConfiguration.psd1
Exception calling "SafeGetValue" with "0" argument(s): "Cannot generate a Windows PowerShell object for a ScriptBlock evaluating dynamic
expressions. Dynamic expression:

Environment data
Attempted from multiple different environments without success
> $PSVersionTable
Name                           Value
----                           -----
PSVersion                      6.1.0
PSEdition                      Core
GitCommitId                    6.1.0
OS                             Darwin 17.4.0 Darwin Kernel Version 17.4.0: Sun Dec 17 09:19:54 PST 2017; root:xnu-4570.41.2~1/RELEASE_X86_64
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion      2.3
SerializationVersion           <IP_ADDRESS>
WSManStackVersion              3.0

> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      6.1.0-rc.1
PSEdition                      Core
GitCommitId                    6.1.0-rc.1
OS                             Darwin 17.4.0 Darwin Kernel Version 17.4.0: Sun Dec 17 09:19:54 PST 2017; root:xnu-4570.41.2~1/RELEASE_X86_64
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion      2.3
SerializationVersion           <IP_ADDRESS>
WSManStackVersion              3.0

> $PSVersionTable
Name                           Value
----                           -----
PSVersion                      5.1.17134.228
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.17134.228
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           <IP_ADDRESS>

@pulkjr is this a real scenario or a test scenario?  Trying to understand how important this is.

I just ran into this myself as I am also seeing this issue with storing record objects in a psd1 file.  At about 3000 lines it returns the error complaining about the presence of a dynamic expression.  My example psd1 attached fails when passed to 'Import-PowerShellDataFile' command.  If you remove one table from the array it imports fine.

The problem seems to be that PowerShell has some hardcoded limits in the AST and for hashtables here.  I did a private build increasing the MaxVisitCount to 10000 (from 5000) and was able to import @39Delta records.txt sample.
@lzybkr what is the impact if we remove these limits altogether?  Seems like it would just be local memory/cpu consumption for a large AST?

Check with @LeeHolmes and/or @JamesWTruher - I think that limit exists to help avoid a DOS style attack.
I suppose it makes sense to add a parameter to the cmdlet to increase the limits.

I couldn't get a definitive conclusion it's safe to completely remove the limits, so we should go with a parameter to set the limits, however, I don't think the user can guess what value to put as it's not the number of lines in the file.  So my proposal is to have a -NoLimit switch that removes the limit check altogether but it's opt-in.

@PowerShell/powershell-committee reviewed this and is ok with -NoLimit


chore: updating go version from 1.19 to 1.20

Description
closes: #XXXX

Author Checklist
All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.
I have...

[ ] included the correct type prefix in the PR title
[ ] added ! to the type prefix if API or client breaking change
[ ] added appropriate labels to the PR
[ ] targeted the correct branch (see PR Targeting)
[ ] provided a link to the relevant issue or specification
[ ] added a changelog entry to CHANGELOG.md
[ ] included comments for documenting Go code
[ ] updated the relevant documentation or specification
[ ] reviewed "Files changed" and left comments if necessary
[ ] confirmed all CI checks have passed

Reviewers Checklist
All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.
I have...

[ ] confirmed the correct type prefix in the PR title
[ ] confirmed all author checklist items have been addressed
[ ] reviewed state machine logic
[ ] reviewed API design and naming
[ ] reviewed documentation is accurate
[ ] reviewed tests and test coverage
[ ] manually tested (if applicable)

Note: this should be merged only after v4.3 is released.

Please update RELEASE NOTES and CHANGELOG


How to shutdown the job scheduler?

Per the apscheduler documentation, the scheduler should be shut down withscheduler.shutdown() but I'm not seeing that anywhere within django-apscheduler.  Is there a recommended way to ensure that the scheduler is shutdown gracefully from within Django?

Where and how the scheduler should be shut down is probably a little implementation dependent.
One example (using BlockingScheduler and a Django management command) is described in the comments here: https://github.com/jarekwg/django-apscheduler/issues/45#issuecomment-659510676.